package { import flash.display.Sprite; import flash.display.Stage; import flash.display.StageScaleMode; import flash.geom.Point; import flash.events.Event; import flash.utils.Timer; import flash.events.TimerEvent; import caurina.transitions.Tweener; import caurina.transitions.Equations; // SWF Metadata [SWF(width="800", height="800", backgroundColor="#ffffff", framerate="31")] /** * @author Hannes Moser */ public class FP10Test extends Sprite { protected var vector:Vector.; public function FP10Test() { stage.scaleMode = StageScaleMode.NO_SCALE; var i:uint = 0; var n:uint = 50; var plane:Sprite; var w:Number; var h:Number; var p:Point = new Point(0, 0); vector = new Vector.(); for(;i < n; i++) { w = Math.random() * 200; h = Math.random() * 200; p.x = -w / 2; p.y = -h / 2; plane = new Sprite(); plane.graphics.beginFill(0xff00ff, Math.min(0.7, Math.max(0.2, Math.random() * 1))); plane.graphics.drawRect(p.x, p.y, w, h); plane.graphics.endFill(); plane.x = Math.random() * 800; plane.y = Math.random() * 800; plane.z = Math.random() * 800 - 400; plane.rotationX = Math.random() * 360; plane.rotationY = Math.random() * 360; plane.rotationZ = Math.random() * 360; this.addChild(plane); vector.push(plane); } this.addEventListener(Event.ENTER_FRAME, this.update); var t:Timer = new Timer(2000, 999); t.addEventListener(TimerEvent.TIMER, this.randomMovement); t.start(); } protected function randomMovement(ev:TimerEvent):void { var i:uint = 0, n:uint = vector.length; var v:Sprite; while (i < n) { v = vector[i]; Tweener.addTween(v, { x:Math.random() * 800, y:Math.random() * 800, z:Math.random() * 800 - 400, transition:Equations.easeInOutElastic, time:1.5} ); i++; } } protected final function update(ev:Event):void { var i:uint = 0, n:uint = vector.length; var v:Sprite; while(i < n) { v = vector[i]; v.rotationX += 4; v.rotationY += 4; v.rotationZ += 4; i++; } } } }