flash on 2010-11-2

by ushisantoasobu
♥0 | Line 57 | Modified 2010-11-02 23:15:50 | MIT License
play

ActionScript3 source code

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

package {
    import flash.geom.Point;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    import caurina.transitions.Tweener;
    
    public class FlashTest extends Sprite {
        
        public var arr:Array;
        public var angle:Number = 0;
        public var addangle:Number = 0;
        public var ichi:Point;
        public var radius:int = 160;
        public var bool:Boolean = true;
        
        public function FlashTest() {
            
            arr = new Array();
            
            for(var i:int = 0; i < 12; i++){
                var pan:panel = new panel(Math.random() * 0xFFFFFF);
                arr.push(pan);
                addChild(arr[i]);
                arr[i].x = stage.stageWidth / 2;
                arr[i].y = stage.stageHeight / 2;                                
            }
            
            var btn:panel = new panel(0x00FFFF);
            btn.x = stage.stageWidth / 2;
            btn.y = stage.stageHeight / 2;
            btn.buttonMode = true;
            btn.useHandCursor = true;
            btn.addEventListener(MouseEvent.CLICK, btnEventHandler);
            addChild(btn);
            
            addangle = 0.012;
            
            this.addEventListener(Event.ENTER_FRAME, loop);
            
        }
        
        private function loop(e:Event):void{
            
            angle += addangle;//(addangle - 0.012) / 36 + 0.012;

            for(var i:int = 0; i < 12; i++){
                
                ichi = new Point();
                ichi.x = this.stage.stageWidth / 2 + radius * Math.cos(angle + i/arr.length*Math.PI*2);
                ichi.y = this.stage.stageHeight / 2 + radius * Math.sin(angle + i/arr.length*Math.PI*2);                
            
                arr[i].x += (ichi.x - arr[i].x) / 1;
                arr[i].y += (ichi.y - arr[i].y) / 1;
                
            }
            
        }
        
        private function btnEventHandler(e:MouseEvent):void{
           addangle = 0.24;
           Tweener.addTween(this, {addangle:0.012, time:1.2, transition:"easeOutSine"});
            /*
            if(bool){
                addangle = 1.84;
                bool = false;
            }else{
                addangle = 0;
                bool = true;
            }
            */
            
        }

    }
}


import flash.display.Sprite;

class panel extends Sprite{
    public function panel(num:Number){
        this.graphics.beginFill(num);
        this.graphics.drawRect(0, 0, 40, 40);
        this.graphics.endFill();
    }

}