简体   繁体   中英

External SWF to External SWF Timeline Communication, Flash, AS2

Flash CS4, AS2

I have made an interactive tour. It can be seen here:

http://www.92YTribeca.org/Tour click on the bottom image

Each of the 4 sections are external swf and loaded on level 1. I want a button on one swf (floorplan) to load another swf (facility rentals) AND pinpoint a specific frame on the swf's timeline.

I have tried many different ways, all end up loading the swf at the first frame and ignore the rest of the code talking about the timeline. I know I could split this swf up into more external swfs and get the result I want, but I would rather use code if I can.

Is what I want to do possible? If so, how do I write the code?

Thanks!

What you want to do is definitely possible. You need to wait until the SWF is loaded before you can tell it to go to a specific frame. The easiest way to do this is using the MovieClipLoader class.

var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(this);

function onLoadComplete(loadedClip) {
    loadedClip.gotoAndStop(5);
}

loader.loadClip("floorplan.swf", targetClip);

That will load floorplan.swf into the placeholder named "targetClip" and, once it's loaded, have to jump to frame 5.

For more info, see the MovieClipLoader documentation: http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001993.html

Since you manage to load them in perfectly I guess that's not the issue. A common issue is that you need to call the "gotoAndStop" function when the clip is fully loaded, you will do that when the onLoadInit handler of the MovieClipLoader listener is invoked.

Try this:

var MC1:MovieClipLoader = new MovieClipLoader();
MClistener = new Object();
MClistener.onLoadComplete = function() {
     trace("LOADED COMPLETED");
};    
MC1.addListener(MClistener); 
MC1.loadClip("Whatever.swf", "adLoader");

I have been looking to communicate between root swf and loaded swf for a while, and this was very useful.

var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(this);
function onLoadComplete(loadedClip) {
  loadedClip.gotoAndStop(2);
}
loader.loadClip("chapter1.swf", targetClip);

The only thing I cant figure out is how to make a on(press) action the communication to frame two of the loaded swf instead of the onLoadComplete action.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM