Hi codemasters, I'm new to this forum and I already have a question which I'm pretty sure u will help me out to find a solution.

I want to play a mc when the mouse is over. And when the mouse is out I want to rewind the mc. I have tried several things but nothing seems to work.

When the mouse is over it plays the mc, but when the mouse is out I get the following error:

Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at 4animarqme_fla::Sprite62_21/onOutHandler()[4animarqme_fla.Sprite62_21::frame1:24]

Also I want to point out that I the script is written on the mc timeline, frame 1 has the following code, while the next frames have "rewind = true;" and the last frame has "rewind = true;
stop();"

HELP!

import flash.events.MouseEvent;

buttonMode = true;
var rewind:Boolean = false;

stop();

addEventListener(MouseEvent.MOUSE_OVER, startLoop)

function startLoop(e:MouseEvent)
{
    rewind = false;
	this.play();
}

addEventListener(MouseEvent.MOUSE_OUT, onOutHandler);

function onOutHandler(e:MouseEvent)
{	
	do
	{
	   prevFrame();
	} while (rewind == true);
	
}

Dani AI

Generated

Note for — the timeout came from a tight, synchronous loop that tried to step frames all at once. Flash’s player halts script execution when a script blocks the main thread for too long, so rewinding must be done over time (one step per frame or via a timer/tween), not inside a do/while or similar immediate loop.

A simple, robust pattern is to step the clip backward inside an ENTER_FRAME handler so each frame of the player moves it one step until the first frame is reached:

stop();

var isRewinding:Boolean = false;

addEventListener(MouseEvent.MOUSE_OVER, onOver);
addEventListener(MouseEvent.MOUSE_OUT, onOut);

function onOver(e:MouseEvent):void {
    isRewinding = false;
    removeEventListener(Event.ENTER_FRAME, stepBack);
    play();
}

function onOut(e:MouseEvent):void {
    if (!hasEventListener(Event.ENTER_FRAME)) {
        addEventListener(Event.ENTER_FRAME, stepBack);
    }
}

function stepBack(e:Event):void {
    if (currentFrame > 1) {
        gotoAndStop(currentFrame - 1);
    } else {
        removeEventListener(Event.ENTER_FRAME, stepBack);
        stop();
    }
}

Alternative approaches: a small Timer (40–60 ms) can produce a controlled rewind speed, or a tweening library can animate a numeric frame index for smoother easing. Important practices: always remove ENTER_FRAME/Timer listeners when done, guard against adding the same listener multiple times, and prefer centralizing logic (main timeline or a class) rather than scattering scripts deep inside nested clips — that avoids scope/multiple-listener bugs.

Troubleshooting hints: trace currentFrame while rewinding to confirm progress, check hasEventListener before adding listeners, and test with simple stop/play control first to ensure mouse events reach the clip (interactive children can interfere).

It's been solved! thanx!

Hi codemasters, I'm new to this forum and I already have a question which I'm pretty sure u will help me out to find a solution.

I want to play a mc when the mouse is over. And when the mouse is out I want to rewind the mc. I have tried several things but nothing seems to work.

When the mouse is over it plays the mc, but when the mouse is out I get the following error:

Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at 4animarqme_fla::Sprite62_21/onOutHandler()[4animarqme_fla.Sprite62_21::frame1:24]

Also I want to point out that I the script is written on the mc timeline, frame 1 has the following code, while the next frames have "rewind = true;" and the last frame has "rewind = true;
stop();"

HELP!

import flash.events.MouseEvent;

buttonMode = true;
var rewind:Boolean = false;

stop();

addEventListener(MouseEvent.MOUSE_OVER, startLoop)

function startLoop(e:MouseEvent)
{
    rewind = false;
	this.play();
}

addEventListener(MouseEvent.MOUSE_OUT, onOutHandler);

function onOutHandler(e:MouseEvent)
{	
	do
	{
	   prevFrame();
	} while (rewind == true);
	
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.