Passing variables between swf's

Posted on 2006-04-09
Medium Priority
Last Modified: 2007-12-19
Hello All,

Beginning with flash only a few weeks ago, I have had to jump right into some pretty tricky areas...  At the moment, my sticking point is trying to pass variables between two swf files.

(Main SWF Loaded From Browser)
        (Child MC in library)
              (Child MC loaded from external)

It is the bottom most SWF which needs the data located in the Main SWF.  In the main swf I have an array defined as:

_global.ArrayObj = new Array();
ArrayObj[0] = new Array({item1:Value, item2:Value, n...})


_global.ArrayObj = new Array();
ArrayObj[0] = new Array(Value1, Value2, n...})

I have also tried several different options such as references using _root with lockroot, direct calls to _parent._parent etc, but nothing appears to work.  However one strange instance, it appears as though when calling this from the bottom most child:

_global.ArrayObj[0] is returns [object Object] however when referencing the items both by name .item1 or by number [0] it returns undefined.

Does anyone have any ideas?

Question by:Anubis2005
LVL 17

Assisted Solution

by:Dushan De Silva
Dushan De Silva earned 1000 total points
ID: 16411982
LVL 34

Accepted Solution

Aneesh Chopra earned 1000 total points
ID: 16412072

you are getting _global.ArrayObj[0] as [object Object], that clearly means you are getting the array object.

I think everything is fine and you are getting the array object.. just not using it with correct syntax

if this is your array on main SWF...
_global.ArrayObj = new Array();
ArrayObj[0] = new Array({item1:Value, item2:Value, n...})
I hope you can access it as shown below:


Author Comment

ID: 16413345
Thank you for your quick comments.

Looking at it again this morning with fresh eyes, I noticed the very trailing end of the array.  It appears as though the items being loaded into the array are being undefined when set and consequentally undefined when being called.  It had me stumped cause I was sure (as is true) that I had the code correct.

Thank you again.

Expert Comment

ID: 16414209
Asked by Author to reopen question. Said he wished to split points.


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question