Search code examples
actionscript-3flashadobe

Simple Pause Feature Not Working


So I am making a simple pause feature that when the mouse leaves the frame, it goes to a specific frame. Here is my code:

import flash.events.Event;
import flash.events.MouseEvent;
stage.addEventListener(Event.ENTER_FRAME, enterFrame);
function enterFrame(e:Event){
}



stage.addEventListener(Event.EXIT_FRAME, exitFrame);
function exitFrame(e:Event)
{
    gotoAndStop(3);
}

Every time I reach this frame, it automatically sends me to frame 3. Did I not use Event.EXIT_FRAME correctly?


Solution

  • Yes this is incorrect EXIT_FRAME and ENTER_FRAME runs every time your program starts and exits a new frame.

    You would benefit more from using MouseEvent.MOUSE_OVER and MouseEvent.MOUSE_OUT if you would like an event when the mouse leaves the stage area.

    Here is a link to the livedocs explaining mouse event functionality:

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/MouseEvent.html