package { import flash.display.*; import flash.events.*; // Import Tweener import caurina.transitions.*; // SWF Metadata [SWF(width="600", height="400", backgroundColor="#000000", framerate="30")] public class ThreeD extends Sprite { private var cont:Sprite; public function ThreeD():void { cont = new Sprite(); addChild(cont); makeChildren(); } private function makeChildren():void { for (var i:uint=100; i>0; i--) { var sp:Sprite = new Sprite(); sp.alpha = 0.8; sp.addEventListener(MouseEvent.CLICK, onClick); sp.graphics.beginFill(Math.random() * 0xFFFFFF); sp.graphics.drawRect(-150, -150, 300, 300); sp.x = Math.random() * 1000 - 500; sp.y = Math.random() * 1000 - 500; sp.z = i * 200; cont.addChild(sp); } } private function onClick(e:Event):void { var sp:Sprite = Sprite(e.target); Tweener.addTween(cont,{x:-sp.x+200,y:-sp.y+200, z:-sp.z+100, time:1}); Tweener.addTween(sp,{rotationY:sp.rotationY-180,rotationX:sp.rotationX-180, time:1}); } } }