AS3 ENTER_FRAME delay in firing

Hi Guys and Girls,

Its been a long time since i’ve posted on this forum. I’ve always just browsed, but never had enough experience to post and answer questions.
I am doing a small project for uni, and im a little stuck with some (probably simple) AS3.

To set the scene… I have a scene, funnily enough, with 5 frames (and several layers). I have navigation buttons back—home—forward, which do not change over the length of the scene.
In each frame (2-5) i have an embedded flv in a movieClip. The idea was to have a listener on the back and forward buttons, when clicked they do either nextFrame(); or prevFrame();.

However, to stop the 5 frames playing (and looping) i put in an action listener for ENTER_FRAME on the first frame (see below).

My problem appears to be the time it takes for the ENTER_FRAME to fire. The timeline plays straight away, and is already on frame 2 before the enter_frame actually stops it.
Can anyone suggest a reason why there is such a delay in the firing of the enter_frame event, and is there a way to solve it without putting in a gotoAndPlay(1); instead of the stop();??

Also, the forward button works, but the back button never appears to be created. Not quite sure why, as its exactly the same code, with just the names changed, and the instance names as well.

Any help is much appreciated, as I’ve been plodding through putting out fires left right and centre, but this one is eluding me.

here’s the code for the first frame. please excuse the terrible naming conventions. to think i actually do computer programming at uni! :azn:


import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.*;

var homeLup:Loader = new Loader();
function homebtnClickLupiae(event:MouseEvent):void
{
	var choicesURL:URLRequest = new URLRequest("1_choices.swf");
	homeLup.load(choicesURL);
	addChild(homeLup);
}
homeBtnLup.addEventListener(MouseEvent.CLICK,homebtnClickLupiae);


//Action Listener for the Forward Button
forwardBtn.addEventListener(MouseEvent.CLICK,forwardClick);
function forwardClick(event:MouseEvent):void
{
	nextFrame();
}

//Action Listener for the Back Button
backBtn.addEventListener(MouseEvent.CLICK,backClick);
function backClick(event:MouseEvent):void
{
	prevFrame();
}

//Event Listener to stop on the first frame
this.addEventListener(Event.ENTER_FRAME,stopFunction);
function stopFunction(event:Event)
{
    stop();
}