# Pen tool - On/Off (AS2)

**URL:** <https://forum.kirupa.com/t/pen-tool-on-off-as2/304318>\
**Category:** flash\
**Created:** [February 5, 2010, 9:53am UTC](https://forum.kirupa.com/t/pen-tool-on-off-as2/304318 "2010-02-05T09:53:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keytar\_Andy](https://avatars.discourse-cdn.com/v4/letter/k/45deac/32.png) [@Keytar\_Andy](https://forum.kirupa.com/u/Keytar_Andy)\
**Post date:** [February 5, 2010, 9:53am UTC](https://forum.kirupa.com/t/pen-tool-on-off-as2/304318/1 "2010-02-05T09:53:15Z")

</div>

Hey!

I’ve been having a problem for the past month or so, and for the life of me I can’t work out how to switch off the pen tool I have in actionscript.

I have the following code in frame 2, and frame one doesn’t have anything, meaning it doesn’t allow the user to draw. However, after returning to frame 1 from frame 2, you can still draw.

Is there anyway to turn off this drawing actionscript completely when going back to the first frame?

```auto
this.attachMovie("cursor_id","cursor_mc",this.getNextHighestDepth(),{_x:_xmouse, _y:_ymouse});
Mouse.hide();
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
pencil._x = _xmouse;
pencil._y = _ymouse;
updateAfterEvent();
};

Mouse.addListener(mouseListener);

this.createEmptyMovieClip("drawing_mc",this.getNextHighestDepth());
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
 this.drawing = true;
drawing_mc.moveTo(_xmouse, _ymouse);
 drawing_mc.lineStyle(3, 0x99CC00, 100);
};

mouseListener.onMouseUp = function() {
this.drawing = false;
};

mouseListener.onMouseMove = function() {
 if (this.drawing) {
drawing_mc.lineTo(_xmouse, _ymouse);
}
updateAfterEvent();
};

Mouse.addListener(mouseListener);

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.DELETEKEY) || Key.isDown(Key.BACKSPACE)) {
}
};
Key.addListener(keyListener);

```

Regards

Andy
