Forked from: mash's wonderFl_KeyVisual_v3 with explanation diff:289 forked from: wonderFl_KeyVisual_v3 with explanation dokomadenobi.. forked:0favorite:0lines:85license : All rights reserved modified : 2008-12-25 19:05:51 Embed Tweet package { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; public class PathDrop extends Sprite { protected var ballColor:Number = 0xFFFFFF; protected var ballSize:Number = 10; protected var gain:Number = .02; protected var spkratio:Number = 0.3; protected var bg:Sprite= new Sprite(); protected var container:Sprite= new Sprite(); protected var count:Number = 0; protected var xLength:int = 20; protected var yLength:int = xLength; protected var margin:int = 2; protected var radian:Number = 0; protected var ballScope:Array = new Array(); protected var bmpsnc:BmpSnatch; public function PathDrop() { init(); } public function init():void { bg.width = stage.stageWidth; bg.height = stage.stageHeight; bmpsnc = new BmpSnatch(); addChild(bmpsnc); //bmpsnc.init(this,bg); for(var i:int=0 ; i<xLength ; i++) { ballScope[i] = new Array(); for(var j:int=0 ; j < yLength ; j++) { var ball:Ball = new Ball(ballSize,ballColor); ball.x = i*(ball.width+margin); ball.y = j*(ball.height+margin); ball.alpha=0; ballScope[i][j] = ball; container.addChild(ball); container.x = stage.stageWidth/2; container.y = stage.stageHeight/2; } } addChild(bg); addChild(container); stage.addEventListener(Event.ENTER_FRAME, onX); //stage.addEventListener(MouseEvent.MOUSE_MOVE, onMmove); } public function onX(e:Event) { count += gain; radian = Math.sin(count) * 4; container.rotation ++; container.x = Math.sin(count)*stage.stageWidth/10 +stage.stageWidth/2; container.y = Math.cos(count)*stage.stageHeight/8 +stage.stageHeight/2; for(var i:int=0 ; i<xLength ; i++) { for(var j:int=0 ; j<yLength ; j++) { var _scope:Sprite = ballScope[i][j]; _scope.x = i*(_scope.width+margin) + radian; _scope.y = j*(_scope.height+margin) + radian; if(Math.random() < spkratio) { _scope.alpha = radian; _scope.scaleX = radian*i/xLength * j/yLength*2; _scope.scaleY = radian*i/xLength * j/yLength*2; } else { _scope.alpha = Math.random(); _scope.scaleX = radian * i/xLength*j/yLength; _scope.scaleY = radian * i/xLength*j/yLength; } } } } public function onMmove(e:MouseEvent) { container.scaleX = container.scaleY = mouseX/stage.stageWidth; container.rotation = mouseY/stage.stageHeight*360; } } } Code Fullscreen Preview Fullscreen rotation alpha scaleX addChild mouseY mouseX scaleY MouseEvent.ENTER_FRAME height width MouseEvent addEventListener Math.cos Math.random Math.sin Array Sprite int Number