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

manyball

Get Adobe Flash player
by Yohei.Hino 28 Jun 2014
    Embed
/**
 * Copyright Yohei.Hino ( http://wonderfl.net/user/Yohei.Hino )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/fMaQ
 */

package
{
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    
    [SWF(backgroundColor=0x000000, width=465, height=465)]
    public class manyball extends Sprite
    {
        private var ball:Array=[];
        public function manyball()
        {
            stage.scaleMode=StageScaleMode.NO_SCALE;
            stage.align=StageAlign.TOP_LEFT;
            
            for(var i:int=0;i<100;i++){
                var b:Ball=new Ball(Math.random()*0xFFFFFF);
                b.x=stage.stageWidth*Math.random();
                b.y=stage.stageWidth*Math.random();
                ball.push(b);
                addChild(ball[i]);
            }
            addEventListener(Event.ENTER_FRAME,onEnterFrame);
        }
        private function onEnterFrame(e:Event):void{
            for(var i:int=0;i<100;i++){
                ball[i].y+=ball[i].vy;
                ball[i].x+=ball[i].vx;
                //下まで行ったら上に行く
                //
                if(ball[i].y > stage.stageHeight+ball[i].r)
                    ball[i].y=0-ball[i].r;
                if(ball[i].y<0-ball[i].r)
                    ball[i].y=stage.stageHeight+ball[i].r;
                if(ball[i].x > stage.stageWidth+ball[i].r)
                    ball[i].x=0-ball[i].r;
                if(ball[i].x<0-ball[i].r)
                    ball[i].x=stage.stageWidth+ball[i].r;
            }
        }
    }
}
import flash.display.Sprite;

class Ball extends Sprite{
    public var r:int;
    public var vy:Number=(Math.random()-0.5)*10;
    public var vx:Number=(Math.random()-0.5)*10;
    public function Ball(color:Number){
        r=30;
        graphics.beginFill(color);
        graphics.drawCircle(0,0,r*Math.random());
        graphics.endFill();
    }
}