Hey all,
Can anyone give a good, accurate description of the relationship between the Display Object hierarchy and nested movie clips?
Here’s my issue: I have a movie clip, that has a few movie clips and text fields inside of it. I need access to those MCs and text fields.
So, I start off with stage.addChild(container_mc). (These are just examples, by the way)
Then I do container_mc.addChild(movieOne_mc), container_mc.addChild(movieTwo_mc), and container_mc.addChild(textOne_txt).
I’ve made sure to import the necessary classes and declare my variables accordingly.
Now I need to access the stuff inside the container. Let’s say I need to change what the text box says.
So I try container_mc.textOne_txt.text = “Hello, world!”;
That throws an error, so I try parent.container_mc.textOne_txt.text = “Hello, world!”;
That throws an error, too. So I try MovieClip(parent).container_mc.textOne_txt.text = “Hello, world!”;
That throws an error… Finally, I try MovieClip(parent.container_mc).textOne_txt.text = “Hello, world!”;
And then I give up and come here.
I’ve had this work before, but only by referencing the name of the movie clips in question.
Ex: MovieClip(parent.getChildByName(currentVideo.toString())).gotoAndStop(2);
Is that the only way to access nested movie clips? I don’t mind giving every single object a name if I have to, I’m just failing to understand if this is the right way to do things or not. And I foresee issues in the future with objects that aren’t movie clips, or with dynamically generated objects.
The only “tutorials” on Display Objects and similar situations such as this that I’ve seen only show the Display Object hierarchy. Is there a more robust collection of information on working with nested movie clips in Actionscript 3 out there, complete with examples?
Any help or further insight would be greatly appreciated.