troubleshooting Question

passing variable between parents and children in AS3

Avatar of section25
section25 asked on
Adobe Flash
7 Comments2 Solutions3052 ViewsLast Modified:
I am loading a clip by using a loader like this:

var url:String;
var request:URLRequest;
var Loader_1:Loader;

url = "home.swf";
request = new URLRequest(url);
Loader_1 = new Loader();
Loader_1.load(request); = "loaded_clip";
Loader_1.contentLoaderInfo.addEventListener(Event.COMPLETE, load_complete);

// the load complete function
// ----------------------------------
function load_complete(e:Event) {
      removeEventListener(Event.COMPLETE, load_complete);

// end of code

Now I simply want to be able to pass a variable either to the child clip from the parent or grab a value from the parent in the child clip, but all of the usual ways that I have seen posted do not work. Is this even possible?

So far I have tried many different variations of:

          MovieClip(parent.parent).whatever = 10;

and nothing is working.

If I try to trace the parent of the child clip, the farthest I can go back is the loader itself. If I try to get the parent of the loader, I get a 'null reference' error. I've given the loaded clip a name of "loaded_clip" and added it as a child of "main_stage", but when I try to get the parent of "loaded_clip", I get the same null reference error.

How the heck do you pass variables when you can refernce the parent clip?

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros