CLICK HERE TO COPY
Actionscript:
stage.frameRate = 30;
var pencil:Shape = new Shape();
addChild(pencil);
var index:int = 0;
var points:Array = new Array();
var circle:Shape = new Shape();
circle.graphics.beginFill(0x000000);
circle.graphics.drawCircle(0,0, 5);
addChild(circle);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onUp);
circle.addEventListener(Event.ENTER_FRAME, onMoveCircle);
function onDown(evt:MouseEvent):void {
pencil.graphics.lineStyle(0,0x000000);
pencil.graphics.moveTo(mouseX, mouseY);
stage.addEventListener(MouseEvent.MOUSE_MOVE, onDraw);
}
function onUp(evt:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onDraw);
}
function onDraw(evt:Event):void {
pencil.graphics.lineTo(mouseX, mouseY);
points.push(new Point(mouseX, mouseY));
}
function onMoveCircle(evt:Event):void {
if (points.length>0) {
[...]