Drawing in ActionScript3

We are going to add to the pencilCursor program so that the pencil draws dots..
Modify the code by adding a few lines:

Or you can download the Flash file.
Mouse.hide(); //hide the real cursor
pencil.mouseEnabled = false; //so you can click on other things, not the pencil
stage.addEventListener(MouseEvent.MOUSE_MOVE,moving);
function moving(e:MouseEvent):void {
  //make the pencil follow the real cursor
  pencil.x=mouseX;
  pencil.y=mouseY;
  this.graphics.beginFill(0x0000FF); //blue
  this.graphics.drawCircle(e.stageX,e.stageY,3);
} //moving
Get Adobe Flash player

There isn't a clear button yet, but you can refresh the stage to start over.

Experiment: Modify the code to draw different colors. Make larger or bigger circles.

We will be adding to this movie throughout this lesson.

NEXT: Extras to add on your own