flash on 2014-10-4

by kjkmr
♥0 | Line 41 | Modified 2014-10-04 22:55:53 | MIT License
play

ActionScript3 source code

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

package {
    import flash.text.TextField;
    import flash.events.MouseEvent;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        
        private var _textField:TextField;
        
        public function FlashTest() {
            // write as3 code here..
            var test:TestDispatcher = new TestDispatcher();
            test.addEventListener( MouseEvent.MOUSE_OVER, _onMouseOver );
            addChild( test );
            
            _textField = new TextField();
            _textField.width = 300;
            _textField.height = 200;
            _textField.y = 120;
            addChild( _textField );
        }
        private function _onMouseOver( event:MouseEvent ):void {
            trace(event.target);
            _textField.text = event.target + "\n" + _textField.text;
        }
    }
}
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.events.EventDispatcher;

class TestDispatcher extends Sprite {
    
    private var _pushButton:Sprite;
    public function TestDispatcher() {
        _pushButton = new Sprite();
        _pushButton.graphics.beginFill(0x666666);
        _pushButton.graphics.drawRect(0,0,100,100);
        _pushButton.name = "pushButton";
        _pushButton.addEventListener( MouseEvent.MOUSE_OVER, dispatchEvent );
        _pushButton.addEventListener( MouseEvent.MOUSE_OVER, _onMouseOver );
        this.mouseEnabled = false;
        addChild( _pushButton );
    }
    
    private function _onMouseOver( event:MouseEvent ):void {
        dispatchEvent( event );
    }


}