Reset Draw API F8 A/S2

Hi,

I have a “marker” tool where the user can click it and then write on the stage. They can click it again and it turns it off and clears the lines made. I’ve also added the a/s to buttons so that when the user navigates through the application it will automatically clear the line and turn the “marker” to off until its activated again. It’s working fine.

My question is:

Is there a way to globally set it so that upon any button being clicked it clears the line and turns the “marker” off? Because I’m starting to realize there are a lot of buttons that would need this code and it would take forever to add to them all. I was thinking maybe if the script could recognize anytime the playback head moved on the timeline it would clear the line and turn it off?

Here is the script:

// set the marker boolean value to false
var apiOn = true;
emptyMarker._visible = true;
crayon2._visible = false;

/*CRAYON A/S*/

var crayonActive = false;
crayon.onPress = function()
{
    crayonActive = !crayonActive;
    if (crayonActive)
    {
        // 1. SETTING THINGS
        _root.createEmptyMovieClip("line", 1);
        myColor = new Color(_root.crayon); 
        myColor.setRGB(0xE31836);
        
        // 2. EVENTS IN _ROOT:
        _root.onMouseDown = function()
        {
            line.moveTo(_xmouse, _ymouse);
            line.lineStyle(3, 0xE31836, 100);
            this.onMouseMove = function()
            {
                line.lineTo(_xmouse, _ymouse);
                updateAfterEvent();
            };
        };
        _root.onMouseUp = function()
        {
            this.onMouseMove = null;
        };        
    } 
    else
    {
        _root.line.clear();
        onMouseDown = null;
        
        myColor = new Color(_root.crayon); 
        myColor.setRGB(0xA8D7EA);
    }
}

Any help/thoughts would be much appreciated!