Reputation: 455
How would I access a MovieClip that I had dynamically added to a parent MovieClip.
So say for example I have a movieclip (mc_a), and within it I created a var like so:
var b:DisplayObject = new mc_b();
I had manually added mc_a to my stage and gave it the "Instance Name": a.
So my question is how do I access b (which is an instance of mc_b) when it is within a (which, in turn, is an instance of mc_a)?
Edit:
I have the following variable referencing a MovieClip located on frame 1 of another MovieClip named "mc_dock":
var btn_pause:DisplayObject = new mc_pause();
I access the dock on the main timeline under frame 1 using the following line:
var dock:mc_dock = new mc_dock();
and then I used the following 2 lines to see if I can access btn_pause from the main timeline (both of which don't work [by that I mean they return "null"]):
trace(dock.btn_pause);
trace(dock.getChildByName("btn_pause");
When running I get a null value for both trace statements and the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at mc_dock/frame1()
Upvotes: 0
Views: 660
Reputation: 6402
a.getChildByName("instanceNAMEhere")
or
just access the variable b
Upvotes: 1