In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Try BetweenAS3

おためしBetweenAS3
Get Adobe Flash player
by yasohachi 22 Apr 2010
    Embed
/**
 * Copyright yasohachi ( http://wonderfl.net/user/yasohachi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/iITs
 */

/**
 *	おためしBetweenAS3
 */

package {
    import flash.display.Sprite;
    import org.libspark.betweenas3.BetweenAS3;
    import org.libspark.betweenas3.tweens.ITween;
    import org.libspark.betweenas3.easing.*;
    import org.libspark.betweenas3.events.*;
    [SWF(backgroundColor="#000000")]
    public class BetweenTest extends Sprite {
    		public var box:Box = new Box();
    		public var objects:Vector.<Vector.<Box>> = new Vector.<Vector.<Box>>();
    		public var tw:ITween;
    		
    		public var dx:int;
    		public var dy:int;
    		
    		public var numx:int;
    		public var numy:int;
        public function BetweenTest() {
        		for(var i:int = 0;i < 23;i++){
        			objects.push(new Vector.<Box>());
        			for(var k:int = 0;k < 23;k++){
        				box = new Box();
        				box.x = 13 + i * 20;
        				box.y = 13 + k * 20;
        				objects[i].push(box);
        				this.addChild(box);
        			}
        		}
        		numx = int(Math.random()*1000)%23;
        		numy = int(Math.random()*1000)%23;
        		box = objects[numx][numy];
        		objects[numx][numy] = null;
            this.removeChild(box);
        		next();
        }
        
        public function next():void{
        		var num:int = int(Math.random()*1000)%2;
        		var prex:int = numx;
        		var prey:int = numy;
        		if(num == 0){
        			if(numx == 0){
        				numx = 1;
        			}else if(numx == 22){
        				numx = 21;
        			}else{
        				num = int(Math.random()*1000)%2;
        				if(num == 0)	numx++;
        				else		numx--;
        			}
        		}else{
        			if(numy == 0){
        				numy = 1;
        			}else if(numy == 22){
        				numy = 21;
        			}else{
        				num = int(Math.random()*1000)%2;
        				if(num == 0)	numy++;
        				else		numy--;
        			}
        		}
        		dx = (prex - numx) * 20;
        		dy = (prey - numy) * 20;
        		//dx = 13 + prex * 20;
        		//dy = 13 + prey * 20;
        		box = objects[numx][numy];
        		objects[prex][prey] = box;
        		objects[numx][numy] = null;
            tw = BetweenAS3.parallel(
            		BetweenAS3.tween(box,{$x:dx},null,0.1,Cubic.easeOut),
            		BetweenAS3.tween(box,{$y:dy},null,0.1,Cubic.easeOut)
            );
            
            tw.stopOnComplete = true;
            tw.addEventListener(TweenEvent.COMPLETE,onComp);
            tw.play();
        }
        
        public function onComp(event:TweenEvent):void{
        		event.target.removeEventListener(TweenEvent.COMPLETE,onComp);
        		next();
        }
    }
}

import flash.display.Sprite;
class Box extends Sprite
{
	public function Box():void{
		
		var r:uint = randomUint();
		var g:uint = randomUint();
		var b:uint = randomUint();
		var color:uint = (r << 16) | (g << 8) | b;
		this.graphics.beginFill(color);
		this.graphics.drawRect(-10,-10,20,20);
		this.graphics.endFill();
	}
	
	private function randomUint():uint{
		var num:uint = 0x80 + int(Math.random()*1000) % 0x80;
		
		return num;
	}
}