flash on 2010-10-18

by ivan.belchev
♥0 | Line 23 | Modified 2010-10-18 05:50:03 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            
            var canvas:Shape = new Shape();
canvas.x=0;
canvas.y=0;
addChild(canvas);
var selectedColor:uint=0x000000;
function startDrawing(event:MouseEvent):void {

    // set up the drawing API with that
    // color starting at the mouse location
    canvas.graphics.lineStyle(5, selectedColor);
    canvas.graphics.moveTo(canvas.mouseX, canvas.mouseY);

    // create an event listener for the mouse
    // moving so that it can draw lines in the canvas
    stage.addEventListener(MouseEvent.MOUSE_MOVE, whileDrawing);
}

function whileDrawing(event:MouseEvent):void {
    // draw a line in the canvas to
    // the new mouse location

}
function stopDrawing(event:MouseEvent):void {
    // prevent mouse movements from drawing
    // anymore lines until startDrawing
    // is called again during mouseDown
    stage.removeEventListener(MouseEvent.MOUSE_MOVE, whileDrawing);
}
stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
//drawingBoard.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
//drawingBoard.addEventListener(MouseEvent.ROLL_OUT, stopDrawing);
        }
    }
}