PDA

View Full Version : Passing Arrays Between Movies



ControlB
July 16th, 2002, 10:36 AM
I have a SWF movie ("bits.swf") with an array ("things") variable in it.

I use loadMovie to load bits.swf into my main movie.

Q: how can I read/use/transfer the values in array "things" from my main movie?

Thanks!

jsk
July 16th, 2002, 11:06 AM
Define an array in the loaded movie and populate it from from the holder movie.
If you've loaded into a level the syntax will be something like myNewArray=_level0.myOldArray.slice()
If you've loaded into a movie clip instance the syntax will be something like myNewArray=_root.myOldArray.slice()

ControlB
July 16th, 2002, 12:12 PM
I need to do the opposite, though: define an array in the holder movie and populate it from the loaded movie (in this case, "bits.swf").

Is there any way of doing that?

jsk
July 16th, 2002, 12:36 PM
Either:

A
Call the loaded array from the loader timeline:
myLoaderArray=_level1.myLoadedArray.slice();
myLoaderArray=instanceName.myArray.slice();

or

B
Throw the loaded array at the loader timeline when it has loaded
i.e. put this in the first frame of "bits.swf"
_level0.myLoaderArray=myLoadedArray.slice();
_root.myLoaderArray=myLoadedArray.slice();

Option B is the more reliable as the swf has definitely loaded and instantiated before the code executes. If you're using option A check that bits.swf has fully loaded before you attempt to reference its properties

ControlB
July 16th, 2002, 01:25 PM
It's working now - thanks for all your help, JSK!