Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : Can you go to a frame within a loaded swf?



walter script
6/1/2004 8:58:21 PM
If I load a swf into a empty movie clip ("empty"), on the base/_root level onf
the main timeline, can I also move to a specific frame within the swf
("external_movie.swf"). I know with a movie clip you give it an instance name
("cars") and write

on (release) {
_root.cars.gotoAndStop(10);
}

How can I give an instance name or reference a loaded swf? Or am I on the
wrong path to figuring out this problem?

My script

on (release) {
loadMovie("external_movie.swf", "empty");
}
Jan-Paul K.
6/1/2004 9:03:49 PM
what you want to do is definetely possible, but since I don't have flash
available right now I have to guess, maybe this works:

on (release) {
_root.empty.gotoAndStop(10);
}

of course you have to check that the movie completed loading before calling
the gotoAndStop on it.
Maybe you should also try the loadMovieNum function.

Regards,
Paul
walter script
6/1/2004 9:35:49 PM
Thanks. I think the problem is that the movie is not fully loaded before I try
to goto a frame within the swf/empty mc as you mentioned. The movie looks like
it loads. The _root.cars.gotoAndStop(10); works on the next frame after the swf
has clealry been loaded. My goal was to load and goto in one shot like the
following:

on (release) {
loadMovie("grand_mc.swf", "empty_holder");
_root.empty_holder.gotoAndStop(2);
}
Jeckyl
6/2/2004 11:24:49 AM
You cannot go to a frame until that frame has been loaded. SWF files do not
load instantly .. the loading does not start until all script for that
frame/event are finished, and even then it can take more than one frame's
worth of time to load even a cached SWF file (only reads the first 8K of a
SWF in the first frame of loading at most).

izzyblizzy
6/2/2004 1:26:05 PM
kglad
6/2/2004 2:05:18 PM
just use preload code:

loadMovie("grand_mc.swf", "empty_holder");
preloadI=setInterval(preloadF,60);
function preloadF(){

if(empty_holder.getBytesLoaded()>0&&empty_holder.getBytesLoaded()>=empty_holder.
getBytesTotal()){
_root.empty_holder.gotoAndStop(2);
clearInterval(preloadI);
}
Branching
6/2/2004 2:25:33 PM
Or try another method, create an mc (e.g. "controller"), stop(); the first
frame, on the second frame put your code _root.empty_holder.gotoAndStop(2);

on the button put the relative code:

on (release) {
loadMovie("grand_mc.swf", "empty_holder");
_root.controller.gotoAndStop(2);
}

:-0

Jack.
6/2/2004 2:41:45 PM
[quoted text, click to view]

this is okay for offline usage,
this would fail in an online situation due to
server lag, Flash does not wait for the
loadMovie() command to complete, and
frame#2 of controller would be visited
long before grand_mc.swf had loaded
enough to go to frame#2.
Stick with the preload as per kglad's post.

Branching
6/2/2004 2:49:09 PM
Just thought that the button controls EMPTY_HOLDER+CONTROLLER then CONTROLLER controls EMPTY_HOLDER, an AB-BA method of psychology ! :-0
AddThis Social Bookmark Button