flash on 2015-12-29

by and
♥0 | Line 39 | Modified 2015-12-29 06:48:10 | MIT License
play

ActionScript3 source code

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

package {
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.display.Sprite;
    import flash.utils.getTimer;
    public class FlashTest extends Sprite {
        
        private var tf:TextField;
        private var isDown:Boolean;
        
        public function FlashTest() {
            // write as3 code here..
            
            
            tf = new TextField();
            tf.width = 200;
            tf.height = 400;
            tf.textColor = 0xFF3333;
            addChild(tf);
            
            //tf.selectable = false;
            //tf.mouseEnabled = false;
            
            
            var s:Sprite = new Sprite();
            s.graphics.beginFill(0xCCCCCC, 0.2);
            s.graphics.drawRect(0,0,200,400);
            s.graphics.endFill();
            s.x = 200;
            addChild(s)
            s.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
            s.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
        }
        
        private function onMouseDown(e:MouseEvent):void
        {
            if(isDown)
            {
                tf.text = "\n ######"+getTimer() + '\n\n' + tf.text;
            }

            tf.text = "D "+getTimer() + '\n' + tf.text;
            isDown = true;
        }
        
        private function onMouseUp(e:MouseEvent):void
        {
            tf.text = "U "+getTimer() + '\n' + tf.text;
            isDown = false;
        }
    }
}