Mouse Coords Detection without OnClipEvent

MX04

I have an application where I need to detect if the mouse is less than 200 px from the left sie of the screen, then play an animation… Once the mouse is moved back out of the 200 px area I want the animation to reverse.

I’m using the Tween Class for animation and have been messing around with onclipevents with no luck like:

onClipEvent (enterFrame) {
if(_xmouse <= 200)
{
_root.theSwitch = “on”;
}else{
_root.theSwitch = “off”;
}

    if(_root.theSwitch=="on")
    {
        trace("on")
    }

}

(This has been dumbed down)

This will obviously produce a million “on” traces when the mouse is over there - what is the best method for detecting the change once, setting a variable, then playing the animation?

Thanks in advance!