Syntax help with accessing instance name, dynamically...
Hey guys, n00b needs help,
I need to play a movie clip whose instance name is set into a dynamic text field. Say, if I were to have a dynamic text field named 'holder', containing the instance name 'mc1', how would I play it?
Considering incorrect syntax, this is what I'm trying to do:
Code:
_root.holder.text.gotoAndPlay(10); //which is incorrect
alternatively,
Code:
var instance_name = _root.holder.text;
_root.instance_name.gotoAndPlay(10); // which is also incorrect.
Hope I'm making sense. That ^ is what I wanna do but I'm looking for the right syntax.
HALP!
What's that? You haven't seen my site yet?? Here you go - Click Me!
Thanks for the post del, but a bit different from what you've said. Let me try to give a clearer picture.
I have a dynamic text field with an instance name of its own called 'txt1'.
I have a movie clip with its own instance name as 'mc1'.
Both objects are on the root of the timeline.
Now, I want to play 'mc1', once I assign txt1.text = mc1; I do not want to play 'mc1' directly by coding _root.mc1.play(); Instead, I want it to wait for the instance name to pop up in 'txt1' to play there and then. Currently I have a conditional statement which is hard coded to each of the instance names. I do not want that and hence am trying to directly access the 'mc1' via 'txt1' which makes the code flexible to play MCs of any instance name.
Am I making sense, anyone?
What's that? You haven't seen my site yet?? Here you go - Click Me!
So you want a movie to load that is named in txt1....
There is an obvious problem in that there is no 'onChange' event in flash so you will either have to make a list of usable movie names or make a button to use when it is right. I'd use the button method.
So you want a movie to load that is named in txt1....
There is an obvious problem in that there is no 'onChange' event in flash so you will either have to make a list of usable movie names or make a button to use when it is right. I'd use the button method.
Well I am using 'onEnterFrame' to check that onChange event. Besides I see you got a counter attached as a string to the movie clip. My 'mc1' name was just an example. In reality, my instance names are all different and don't have a uniform name. All I need to do is read a string from the dynamic text file which has the SAME name of an instance present in my movie, to do whatever action I require it to do.
I've attached a fla. Run it and see what I'm trying to do. All I want now is to remove the switch cases for the 3 rectangles below. I do not want to restrict the conditions to just red, yellow and green, but instead looking for a solution which would simply read whatever string I have to play the corresponding movie clip, which in this case, I have named them as per color.
Now, am I making sense?
What's that? You haven't seen my site yet?? Here you go - Click Me!