flash on 2010-6-30

by aaharu
♥0 | Line 59 | Modified 2010-06-30 18:03:36 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    
    public class FlashTes extends Sprite {
        private var ball:Sprite;
        private var a:int = 0;
        private var b:int = 0;
        private var c:int = 0;
        
        public function FlashTes() {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            
            ball = new Sprite();
            ball.graphics.beginFill(0xFF0000);
            ball.graphics.drawRect(-10, -5, 20, 10);
            ball.graphics.endFill();
            ball.x = 50;
            ball.y = 50;
            addChild(ball);
            
            var text1:TextField = new TextField();
            text1.text = "X";
            text1.addEventListener(MouseEvent.CLICK, onClick);
            addChild(text1);
            var text2:TextField = new TextField();
            text2.text = "Y";
            text2.y = 50;
            text2.addEventListener(MouseEvent.CLICK, onClick);
            addChild(text2);
            var text3:TextField = new TextField();
            text3.text = "Z";
            text3.y = 100;
            text3.addEventListener(MouseEvent.CLICK, onClick);
            addChild(text3);
            
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
            stage.addEventListener(MouseEvent.CLICK, onClick);
        }
        
        private function onEnterFrame(e:Event):void {
            ball.rotationX += a;
            ball.rotationY += b;
            ball.rotationZ += c;
        }
        
        private function onClick(e:MouseEvent):void {
            switch(e.target.text) {
                case "X":
                    a = 5;
                    break;
                case "Y":
                    b = 5;
                    break;
                default:
                    c = 5;
                    break;
            }
        }
    }
}