Skip to main content
Participant
December 27, 2012
Answered

gotoAndPlay won't go to certain frame labels? All because of a harmless mc?

  • December 27, 2012
  • 1 reply
  • 15403 views

let's say I have a timeline with 5 keyframes, each labelled. Let's call them:

"one", "two", "three", "four", "five"

On all three I have a stop();

And on frame "one" I also command it to go to frame "two" with gotoAndPlay("two");

Test play, and it works.

Same works with gotoAndPlay("three") and "four", but when I try gotoAndPlay("five");

it somehow plays "four" instead. Stranger still is that when I switch the order of the keyframes to "one", "two", "three", "five", "four", it plays frame "five" just fine.

I isolated the problem thinking it was a stray code, but it wasn't.

It was a movieclip with no code, no linkage whatsoever. If it was there, the error was there. If I delete it, the error is gone.

What is this? I've never encountered such a problem.

Using Flash CS6.

This topic has been closed for replies.
Correct answer kglad

Hm that would seem logical, the fact that it's trying to go to a frame that's not yet loaded.

Everything goes screwy when I try to load something past frame 50 (Note than within this 50 frames are actually lots of frames. Instead of a timeline filled with tweens and animations, I contain each scene in a movie clip.

Yes I am doing it when it first starts.

No, no preloaders.

So what's the solution here? Use a preloader?

I'm no coder so I don't know to make a prealoder, but would a 'title screen' of some sort help? A play button on the first frame so that it loads in the background first before I press the button to play the animation?


on frame 1 use:

stop();

this.loaderInfo.addEventListener(Event.COMPLETE,gotoF);

function gotoF(e:Event):void{

gotoAndPlay("five");

}

// if that works, please mark helpful/correct responses

// if that fails, upload your fla to a file server and post a link.

1 reply

Participant
December 27, 2012

UPDATE things got ever weirder.

This mysterious 'harmless' movieclip was actually one of four inside another movieclip.

Let's call them: A, B, C and D.

At first I came to the conclusion that A was the problem, since the problem would disappear when I deleted A and not when I deleted B, C, D.

In a strange twist, if I kept deleting and undoing, A would no longer be the problem. Now, B had to be deleted for the issue to go away. Then C, then D.

This is weird.

kglad
Community Expert
Community Expert
December 27, 2012

this is a common problem when executing a goto before the needed frame is loaded.  so:

1.  what's the frame number of the highest frame with one of your labels?

2.  are you executing a gotoAndPlay() when your swf first starts?

3.  are you doing anything (like using a preloader) to ensure the needed frames are loaded before executing your gotoAndPlay?

kglad
Community Expert
Community Expert
December 28, 2012

Awesomesauce, issue resolved. This way is much more graceful than my jury rig. I'm merely a beginner at AS3 so I'm unfamiliar with this type of listener.

Thank you so much for your help.

Cheers ^ ^


you're welcome.