all groups > flash actionscript > january 2005 >
You're in the

flash actionscript

group:

gotoAndPlay issue


gotoAndPlay issue EnglishSpringer
1/4/2005 9:27:55 PM
flash actionscript: OK...this is going to make me sound really stupid but I just cannot get this to
work and its frustrating me to no end. For testing purposes i have a 10 frame
movie clip sitting on the stage (movTest) that has a stop() command in frame 1
and frame 10. In the main timeline I have the command movTest.gotoAndPlay(2); -
the goal is to start the movie clip at frame 2 and have it run right through to
the end of frame 10. However, what happens is that it goes to frame 2 and
stops. The only way I can get the timeline to continue on its own is to place a
play() command in frame 2. This seems really silly to me. Does anyone have any
ideas as to why its doing this???? Thanks in advance Derek
Re: gotoAndPlay issue NSurveyor
1/4/2005 10:16:02 PM
If that is the case, you could do:

On your frame 1 of your mc, place:

stop();
someVar = 1;

Then when using gotoAndPlay, use:

onEnterFrame = function(){
if(movTest.someVar == 1){
movTest.gotoAndPlay(2);
delete(onEnterFrame);
}
}
Re: gotoAndPlay issue Jeckyl
1/5/2005 8:58:38 AM
It could be a matter of timing. If the movTest.gotoAndPlay(2) is in the
same frame as where movTest is placed, then would could be happening is that
the movTest.gotoAndPlay(2) is happening BEFORE movTest has executed the
stop() in frame 1. That will mean that what will happen is movTest will go
to frame 2, and THEN execute the code in frame 1 (that was already waiting
to execute) and THEN execute any code in Frame 2. Putting in some trace
statements in you main timeline and in movTest should verify this.

Try delaying the movTest.gotoAndPlay(2) until a frame after movTest is
placed.
--
All the best,
Jeckyl

Re: gotoAndPlay issue Jeckyl
1/5/2005 9:26:13 AM
Seeing onEnterFrame does not execute until the FOLLOWING frame (onEnterFrame
does not, as some people thing, execute every frame, just every frame from
the second onwards), then that would work, but you may be better just
putting the script on the following frame anyway. There are various
workaround for such timing issues, for example, you can use some tricks to
force some code to happen AFTER the clip does its stop() action. For
example

main timeline:
frame 1:
this.gotoAndPlay(2);
frame 2:
movTest.gotoAndPlay(2);

Order of execution of scripts is an (almost) undocumented area of Flash
Player internals and can cause(when it bites) all manner of grief.
--
All the best,
Jeckyl

Re: gotoAndPlay issue fugya
5/4/2005 12:00:00 AM
Hi,
I had the same problem and solved it by moving the stop() command on the frame
that calls the gotoAndPlay.

ie:
This acts like a gotoAndStop...

function test(){
gotoAndPlay(5);
}
test();
stop();


While this acts like a gotoAndPlay...

stop();
function test(){
gotoAndPlay(5);
}
test();


My suspicion is there has been a change in the way actionscript is handled in
MX. In older versions if flash ran into a gotoAndPlay it would execute
immediately and ignore any script that it hasn't read yet. I think mx reads the
entire script on a frame and executes it in that order. So the stop command is
in the script queue it's just being executed on another frame because of the
gotoAndPlay command.


Chad

Re: gotoAndPlay issue Jeckyl
5/4/2005 12:00:00 AM
[quoted text, click to view]

That is 100% correct behaviour. If the last thing you do is call 'stop()',
then it will stop. if the last thing is gotoAndPlay it will play

[quoted text, click to view]

No.. that's rubbish .. Flash has NEVER EVER done that. You're simply
confused.

[quoted text, click to view]

That is what flash has always done, ever sine the dawn of time.

Jeckyl

AddThis Social Bookmark Button