In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

オレオレMouseEventを発行してみる

Get Adobe Flash player
by yd_niku 25 Feb 2010
/**
 * Copyright yd_niku ( http://wonderfl.net/user/yd_niku )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/tNxu
 */

package {
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
    import flash.geom.*;
    import com.bit101.components.*;
    import frocessing.color.*;
    import flash.text.TextField;
    public class FlashTest extends Sprite {
    		private var _target:IEventDispatcher;
    		
    		private var _timer:Timer = new Timer(200);
    		
    		private var _checkbox:CheckBox;
    		private var _text:TextField;
    		private var c:FColor;
        public function FlashTest() {
        		_target = stage;
        		
        		//
        		_target.addEventListener(MouseEvent.CLICK,clickHandler);
        		_timer.addEventListener(TimerEvent.TIMER,timerHandler);
        		
            c = new FColor();
            c.hsv( 0, 1, 1 );
            
        		_checkbox = new CheckBox( stage, 10, 10, "auto", onChange );
        		_text = new TextField;
        		_text.x = 100; _text.width = 300; _text.height= 300;
        		_text.mouseEnabled = false;
        		addChild(_text);
        }
        private function onChange(e:Event):void{
        		if(_checkbox.selected){
        			_timer.start();
        			graphics.clear();
        		}
        		else{
        			_timer.stop();
        			graphics.clear();
        		}
        }
        public function clickHandler(e:MouseEvent):void{
        		if( e.target != _target ) return;
        		
        		c.h+=3;
        		graphics.beginFill(c.value);
        		graphics.drawCircle( e.stageX, e.stageY, 6 );
        		graphics.endFill();
        	}
        	private function timerHandler(e:TimerEvent):void{
        		_target.dispatchEvent(new MouseEvent(MouseEvent.CLICK,true,false,
        			Math.random()*465, Math.random()*465) );
        	}
        	
    }
}