|
-
[as3] gotoAndPLay(528); starts at 393?
I have a rather long animation that's approximately 600 frames long. I have a layer at the very top of my animation with the code "gotoAndPlay(528);" which should take me to frame 528 as soon as I test my animation via Ctrl-Enter. However, instead of going to frame 528, it is starting at frame 393. I don't have any other code on any other layer at all, anywhere else. This has happened to me before with other animations.
I have it skip all the way ahead because that's where I'm currently working (frames 528 - 600 ish) and I want to see how my animation is looking at that point when i test my animation out, so i can skip watching all the earlier stuff i've already done.
Has anyone else experienced this? gotoAndPlay falling short and not getting to its intended frame destination?
I also tried labeling a frame "go here" and using "gotoAndPlay("go here");" and it still goes to frame 393 and plays from there.
thanks for any help!
-
Bearded (M|G)od
More than likely, it sounds like those frames aren't quite loaded yet, so it goes to the last one that is.
If you have a preloading script, you can put the gotoAndPlay after the preload and it should work just fine.
Does it consistently start from 393 or is it slightly different each time?
-
I can try a preloader script.
and yeah, it consistently goes to frame 393. I even tried "gotoAndStop(528);" and it still only went to 393. And I tried "gotoAndStop("start here");" where the frame with the label "start here" is at frame 528.
A preloader is usually used when someone is downloading the swf via the internet and the file is large, but I'm testing video inside of the flash authoring tool, it should have the whole swf, right? it's instantly preloaded, right? hmmm.. I'll try it and see how it goes.
-
Bearded (M|G)od
Nothing is "instantly" preloaded. From your computer, it's quick, but it just may not be quick enough. Swf's work progressively. Meaning, once a frame is loaded, it will begin to play. So if you had a long animation, you can technically write a preloader that works as a buffer. Say, waits until the first 200 frames are loaded, then begins playing.
But in your case, since code is executed on frame 1, the instant frame 1 is loaded, it hasn't taken that split second time for frame 528 to be loaded, so it's jumping to the closest frame possible.
-
awesome, i'll definitely throw some preloader code in at the beginning and see how it goes. Thanks for your input! I'll let you know how it goes.
-
I added this code at the beginning of my animation:
this.loaderInfo.addEventListener(Event.COMPLETE, onRootLoaderComplete);
function onRootLoaderComplete (event:Event):void
{
trace("Loaded: "+event.target.bytesLoaded);
this.gotoAndPlay(582);
}
And it totally did the trick. I thought that by default, if you don't have a preloader, flash downloads the whole swf first, before playing it. I guess not though? Or maybe, since on the very first frame I asked it to leap to frame 582, it didn't have time to load the animation? Either way, putting a simple preloader in the beginning totally did the trick. thanks!
-
Bearded (M|G)od
Yep, no problem. When you think about it, it makes sense.
Regardless of where it's being loaded from, it does take SOME time to load. Even if it's being read from your hard drive. It's being loaded progressively, meaning, starting at frame 1, and onward. Frame 1 is loaded first, and you're telling it to jump to frame 582. In that split second of frame 1 being loaded and the code executed, frame 582 wasn't loaded yet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|