flash on 2009-11-9

by jules
♥0 | Line 26 | Modified 2009-11-09 09:16:38 | MIT License
play

ActionScript3 source code

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

package{
	import flash.display.Sprite;
	import flash.events.MouseEvent;

        public class Artist extends Sprite{
	    //Are we drawing or not?
            private var drawing:Boolean;
 
            public function Artist(){
                graphics.lineStyle(1,0x000000);
		drawing = false;//to start with
		stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
		stage.addEventListener(MouseEvent.MOUSE_MOVE, draw);
		stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
	    }

            public function startDrawing(event:MouseEvent):void{
		//move to the correct starting position for drawing
		graphics.moveTo( mouseX, mouseY);
		drawing = true;
            }
            
            public function draw(event:MouseEvent){
		if(drawing){
			graphics.lineTo(mouseX,mouseY);
		}
	    }

	public function stopDrawing(event:MouseEvent){
		drawing = false;
	}
}
}