flash on 2011-3-31

by kaminaly
♥0 | Line 34 | Modified 2011-03-31 14:19:46 | MIT License
play

ActionScript3 source code

/**
 * Copyright kaminaly ( http://wonderfl.net/user/kaminaly )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/8LmD
 */

package {
    import flash.display.Sprite;
    import flash.events.*
    
    public class FlashTest extends Sprite {
        private var _tama:Sprite;
        private var _tamaList:Array;
        private var _count:Number;
        
        public function FlashTest() {
            // write as3 code here..
            addEventListener(Event.ENTER_FRAME, onDraw);
            
            _tamaList = [];
            var len:int = 10;
            while(len--){
                var tama:Sprite = new Sprite();
                tama.graphics.beginFill(Math.random()*0xFFFFFF);
                tama.graphics.drawCircle(0,0,10);
                addChild(tama);
                _tamaList[_tamaList.length] = tama;
            }
            _count = 0.0;
        }
        
        private function onDraw(e:Event):void
        {
            _count += 0.5;
            var sin:Number = Math.sin(_count);
            var cos:Number = Math.cos(_count);
            var len:int = _tamaList.length;
            while(len--){
                var tama:Sprite = _tamaList[len]
                 tama.x += (mouseX - tama.x) * (0.01 * len + cos * 0.1);
                 tama.y += (mouseY - tama.y) * (0.01 * len + sin * 0.1);
            }
            
        }
    }
}