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

quickTest

shapes moving randomly on x
Get Adobe Flash player
by benc 18 Jun 2011
    Embed
/**
 * Copyright benc ( http://wonderfl.net/user/benc )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/o0RY
 */

package {
    
    // QUICK TEST
    // author : benc.
    
    import flash.display.Sprite;
    import flash.events.Event;
    
    [SWF(width="320", height="320", frameRate="40")]

    public class FlashTest extends Sprite{
        
        private var rectangle:Sprite;
        private var loop:int = 70;
        private var maxSpeed:int = 30;
        private var maxH:int = 15;
        private var maxW:int = 250;
        
        public function FlashTest() {
            for (var i:int = 0; i < loop; i++) {
                rectangle = new Sprite();
                rectangle.graphics.beginFill(Math.random() * 0xFFFFFF);
                rectangle.graphics.drawRect(0, 0, Math.random() * maxW, Math.random() * maxH);
                rectangle.name = "r" + i;
                rectangle.x = Math.random() * stage.stageWidth;
                rectangle.y = Math.random() * stage.stageHeight; 
                this.addChild(rectangle);
            }
            
           this.addEventListener(Event.ENTER_FRAME, go);   
        }
        
        private function go(e:Event):void {
            for (var i:int = 0; i < loop; i++) {
                getChildByName("r" + i).x += 1 + Math.random() * maxSpeed;
            
                if (getChildByName("r" + i).x > stage.stageWidth) {
                    getChildByName("r" + i).x = 0 - maxW;
                    getChildByName("r" + i).y = Math.random() * stage.stageHeight;
                }
            }
        }
        
    }
}