I have to do what I thought was a simple thing:
A cue point comes into my function and is read. I find the name of that cue point (which is the name of the MC it will act upon) and convert it from a string to an object name so I can work on it. Here's how I do that:
trace (event.name); // output: "childMovieClipA" <==this is a string.
newChildObjectName = this[event.name];
trace ( newChildObjectName.name ); // output: "childMovieClipA" <==this is an object..
That works. How do I make the name of another related MC by adding a string to the event.name and then convert that string to an object name?
I'm trying to create the name of this MC: "childMovieClipA_grandChild"
For example, I'm trying to do this below but get an error:
newGrandChildObjectName = this [event.name + "__grandChild"];
trace ( newGrandChildObjectName.name ); //TypeError: Error #1010: A term is undefined and has no properties.
Any help is appreciated.
In your example it appears you use two underscore characters whereas what you say you want to create appears to only have one.
The way you say you want it places it at the same child level as the event.name object. Just in case, if the _grandchild is a child of the event.name object, you need to use a separate pair of brackets for it.
I had a fundamental misunderstanding of how the "this[ ]" works.
I now do:
newGrandChildObject = this[event.name][event.name + "_gc"];
..and it works.