flash on 2012-6-30
/**
* Copyright Youth-K ( http://wonderfl.net/user/Youth-K )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sBb3
*/
package {
import flash.display.Sprite;
public class FlashTest extends Sprite {
private var ba:Ball;
private var xPos:Number;
private var yPos:Number;
public function FlashTest() {
for(var i:Number=0; i<100; i++){
xPos = Math.round(Math.random()*stage.stageWidth);
yPos = Math.round(Math.random()*stage.stageHeight);
ba = new Ball(xPos,yPos);
this.addChild(ba)
}
}
}
}
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;
class Ball extends Sprite{
private var bl:Sprite = new Sprite();
private var timer:Timer;
private var counter:int;
public function Ball(xPos:Number,yPos:Number){
bl.graphics.beginFill(0x000000);
bl.graphics.drawCircle(xPos,yPos,5);
bl.graphics.endFill();
this.addChild(bl);
timer = new Timer(33);
timer.addEventListener(TimerEvent.TIMER,loop);
timer.start();
}
public function loop(e:TimerEvent):void{
bl.x += Math.sin(100*Math.random()*counter);
bl.y += Math.cos(100*Math.random()*counter);
counter++;
}
}