flash on 2012-6-29
/**
* Copyright kevin-chen ( http://wonderfl.net/user/kevin-chen )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/gJyT
*/
/**
TEST
KEVIN-CHEN@FOXMAIL.COM
From China
**/
package {
import flash.geom.Point;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
init()
}
private var list:Vector.<RotationBox>
private function init():void
{
list=new Vector.<RotationBox>()
for(var i:int=0;i<200;i++)
{
var box:RotationBox=new RotationBox(new Point(150+Math.random()*150,150+Math.random()*150))
this.addChild(box)
list.push(box)
}
var timer:Timer=new Timer(1000/30)
timer.addEventListener(TimerEvent.TIMER,timerHandler)
timer.start();
}
private function timerHandler(e:TimerEvent):void
{
for each(var box:RotationBox in list)
{
box.render()
}
}
}
}
import flash.geom.Point;
import flash.display.Sprite;
class RotationBox extends Sprite
{
private var centerPoint:Point
public function RotationBox(centerPoint:Point):void
{
this.centerPoint=centerPoint
init()
}
private var box:Sprite
private function init():void
{
box=new Sprite()
this.addChild(box)
var size:int=Math.random()*20
box.graphics.beginFill(Math.random()*uint.MAX_VALUE,0.5)
box.graphics.drawCircle(-size/2,-size/2,size)
box.graphics.endFill()
speed=Math.random()*(180/Math.PI)
radius=Math.random()*200
}
private var speed:Number
private var radius:int
public function render():void
{
box.x=this.centerPoint.x+Math.sin(speed)*radius
box.y=this.centerPoint.y+Math.cos(speed)*radius
box.rotationZ=Math.cos(speed)*50
box.rotationY=Math.sin(speed)*50
speed+=0.1
}
}