flash on 2010-2-26

by yaha
♥0 | Line 28 | Modified 2010-02-26 15:45:14 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    public class DrawDemo extends Sprite {
    	
    		private var is_clicked :Boolean = false;
    		private var lastx :Number = 0;
    		private var lasty :Number = 0;
    		
    		public function DrawDemo() {
    			graphics.lineStyle( 4, 0xEA594F );
    			stage.addEventListener( MouseEvent.MOUSE_DOWN, function(e :MouseEvent) :void{
    				is_clicked = true;
    				lastx = mouseX;
    				lasty = mouseY;
    				graphics.moveTo( lastx, lasty );
    			});
    			stage.addEventListener( MouseEvent.MOUSE_MOVE, function(e :MouseEvent) :void{
    				if ( is_clicked ) {
    					graphics.lineTo( mouseX, mouseY );
    				}
    				lastx = mouseX;
    				lasty = mouseY;
    			});
    			stage.addEventListener( MouseEvent.MOUSE_UP, function(e :MouseEvent) :void {
    				is_clicked = false;
    			});
    		
    		}
    } 
}