-
Loading External SWF
I'm using Flash CS4 and AS2. I have an external swf that works fine, but when I try to load it into another swf part of it doesn't work. The swf that's loading it is in the exact same directory so it's not missing any files. It's a little hard to explain, and would probably be easier if you could see it, however, even zipped the file is rather larger at 23 mb, so I can't attach it.
-
roger, the swf is 23mb?
without actually seeing the file one of the first things that come to mind is the file you are loading probably has actionscript that includes "_root" Is this the case?
-
Hi bgregus. No, the swf isn't that big, but it uses an images folder which bulks up the size. I could attach just the .swf but it wouldn't really function. As for the actionscript, yes, it does include "_root". Is this a problem?
-
Roger,
What I think is happening is your external swf (lets call that swf A) has code pointing to it's _root but once you load swf A into swf B all those _root references now point to the _root of swf B.
You might go through the swf you are loading up and remove all references to _root and instead use relative paths.
OR if you don't want to figure out all the relative paths
Say in swf B you are loading swf A into a movieClip called "holder_mc". Find all uses of _root in swf A and insert the holder_mc into the path "_root.holder_mc.whatever"
does that make sense?
-
That worked! Thank you so much; you're a lifesaver. So glad I'll know this from now on :)
-
-
Hi guys is it possible to load an external swf with a parameter which the external swf needs to operate?
-
jonis - you could use the same _root trickery to set a variable in the file that is doing the loading. Then the loaded swf could look for the variable at _root. AKA
PHP Code:
if(_root.userChoice == 1){
// play movie 1 code
} else {
// play movie 2 code
}
I'm not sure if that is what you are talking about though.
-
i want to use on the parent swf something like
PHP Code:
ContainerClip.loadMovie("external.swf", my_variable);
or
PHP Code:
ContainerClip.loadMovie("external.swf?my_variable=" + my_variable);
and each time pass a different "my_variable"
Will the second solution work?Do i have to "GET" somehow the my_variable in the code of the external.swf?
-
jonis - Gotcha, I haven't tried doing it like that.
Usually I just set the "my_variable" in the parent file and then have the external swf look for "my_variable" on init or whatever function. Might want to start a new thread to see if someone more experienced has any input on an alternate way to pass directly into the swf.
- B