views:

2354

answers:

4

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!

A: 

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

thehiatus
ok still not working... Here's the code that I'm using:btnFLRcafe.onRelease = function(){var loader:MovieClipLoader = new MovieClipLoader();loader.addListener(this);function onLoadComplete(loadedClip) { loadedClip._root.mcRENTALS.gotoAndStop("CAFE");}loader.loadClip("maps_92Tri_RentalsMain.swf", 1);}I've put this code on the actions timeline in the MC that has the button (btnFLRcafe).
jecca411
cont.When btnFLRcafe is pressed I want it to load "maps_92Tri_RentalsMain.swf" to level 1 and play the frame named "CAFE" from within the MC "mcRENTALS".Right now, the button loads "maps_92Tri_RentalsMain.swf" to level 1, but it does not go to "CAFE" on the timeline. Please help! Thanks!
jecca411
Your problem may be one of scope. Since, if I'm reading this right, the loader and listener are all declared inside the onRelease function. Try declaring them outside the onRelease event and just calling loader.loadClip() inside of it. Scoping can be weird in AS2, especially when using "this". You can also try setting a variable outside of the onRelease function (var t=this;) and then adding the listener to that variable: loader.addListener(t); I'd also put some traces in to see if the onLoadComplete event is ever being called.
thehiatus
Still not working. onLoadComplete is not being called... the trace does not show up.I don't know what to do.
jecca411
Maybe try moving the code out of the movie clip and into the main timeline. If the movieclip containing the code doesn't exist when the new .swf is loaded, the onLoadComplete event will never be received. Does _root.mcRENTALS.gotoAndStop("CAFE") go to a frame where the clip containing btnFLRcafe is removed or altered? You can also just move the listener to the root clip: load.addListener(_root) and then put the onLoadComplete function in the root clip.
thehiatus
A: 

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.

Theo.T
A: 

Try this:

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

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.

Richard A
For a follow-up query better post a new question, more people would see it that way.
sth
I couldn't get this to work.. I used this code:btnFLRcafe.onRelease = function(){loader.loadClip("maps_92Tri_RentalsMain.swf", 0);}var loader:MovieClipLoader = new MovieClipLoader();loader.addListener(this);function onLoadComplete(loadedClip) { loadedClip.gotoAndStop("CAFE");}I tried all sorts of arrangments... This will load the swf, but it's still not moving down the timeline. I think it looks like I'm going to have to make the 2 externals into one..
jecca411