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

flash actionscript : TARGETING A TIMELINE FROM A EXTERNALSWF IN A MC


d9
3/20/2004 11:36:52 PM
Hi-
I have a site with multiple swfs that I'm loading into movie clips. I am just
learning how to do this and I can load the swf fine(I think!) but that swf has
multiple shoes on it and if the user clicks on shoe "3" for example not just
the first one in the timeline, I can't get the button to talk to the swf and
tell it to stop on shoe "3". It keeps just going to the first frame in the
timeline. I tried the labels, just calling out the frame number...I'm really
confused, please help!!!

So I guess I need help with targeting a frame on a external swf timeline? My
ghetto code is below... thanks!!


on (release){
_root.eachShoe_mc.loadMovie("Revival.swf")
gotoAndStop("revival_wht")
}
kglad
3/20/2004 11:56:46 PM
you can't reference a frame (or anything else in the loaded swf) until loading
completes. then you should reference the frame of the target movieclip. for
example:

on (release){
_root.eachShoe_mc.loadMovie("Revival.swf")
clearInterval(preloadI);
preloadI=setInterval(preloadF,100);
}

and attached to a frame

function preloadF(){

if(_root.eachShoe_mc.getBytesLoaded()>50&&_root.eachShoe_mc.getBytesLoaded()>=_r
oot.eachShoe_mc.getBytesTotal()){
clearInterval(preloadI);
_root.eachShoe_mc.gotoAndStop("revival_wht")
}
}
Ed Massey
3/20/2004 11:58:53 PM
You need to put stop(); in each frame that you want to stop at....

hth

Ed


[quoted text, click to view]

d9
3/21/2004 12:09:38 AM
Ed-
d9
3/21/2004 12:32:09 AM
KGLAD-
That works, but I have multiple buttons that need to target more then one
label on the external swf's timeline. Any ideas on that? So all the code you
gave me goes on the swf with the button on it, not on the swf i'm trying to
target a specific frame?
kglad
3/21/2004 7:56:52 AM
there's always a main movie at _level0. that movie should contain the code to
direct you movie to whichever frame. you can attach different code to each
button in your main movie. for example:

attached to button 1:

on(press){
_root.eachShoe_mc.loadMovie("Revival.swf")
clearInterval(preloadI);
preloadI=setInterval(preloadF,100,"frame1");
}
and attached to button 2:
on(press){
_root.eachShoe_mc.loadMovie("Revival.swf")
clearInterval(preloadI);
preloadI=setInterval(preloadF,100,"frame2");
}

and attached to a frame:

function preloadF(frameLabel){

if(_root.eachShoe_mc.getBytesLoaded()>50&&_root.eachShoe_mc.getBytesLoaded()>=_r
oot.eachShoe_mc.getBytesTotal()){
clearInterval(preloadI);
_root.eachShoe_mc.gotoAndStop(frameLabel)
}
}
d9
3/21/2004 8:21:53 AM
Thank You Kglad, I got that to work! Now, my last question.
I notice all the Preload info in the code, what do I do with that? Do I make a
preloader for the each swf(each shoe model w/colorways is it's own swf)? That's
the only part I'm confused about now. I am not a preloader whiz, so if you
could explain that it would be most appreciated.
kglad
3/21/2004 6:04:06 PM
you can use the same preloader code for each of your loadMovie() statements, if
you're using the same target movieclip in your loadMovie() statements. if you
have different target movieclips the code can be amended to pass that variable
to an amended preloadF(). for example, attached to one of your buttons you
might have:

on(press){
_root.eachShoe_mc.loadMovie("Revival.swf")
clearInterval(preloadI);
preloadI=setInterval(preloadF,100,"frame1",_root.eachShoe_mc);
}

while on another you might have:

on(press){
_root.eachHat_mc.loadMovie("Revival.swf")
clearInterval(preloadI);
preloadI=setInterval(preloadF,100,"frame1",_root.eachHat_mc);
}

and you would amend preloadF() to look like:

function preloadF(frameLabel, targetMC){

if(targetMC.getBytesLoaded()>50&&targetMC.getBytesLoaded()>=targetMC.getBytesTot
al()){
clearInterval(preloadI);
targetMC.gotoAndStop(frameLabel);
}
}
AddThis Social Bookmark Button