I have a MC with an instance name, ‘JOE’.
I have a dynamic text field with an instance name, ‘EMP_NAME’.
The text field is set to “” default.
Upon runtime, I assign a text value of ‘JOE’ into ‘EMP_NAME’.
Hence, _root.EMP_NAME.text = “JOE”;
Once that’s done, I want the MC to check the text in ‘EMP_NAME’, and play if the text is ‘JOE’.
As of now, I have an ‘if’ statement to do that check. Since I’m going to have many MCs I do not want to add more ‘if’ statements or ‘switch’ cases as that would simply be hardcoding. I want to add more MCs with unique instance names like ‘JOE’, ‘RICK’, ‘PAT’ etc. and should correspondingly play the MC whose instance name matches to that assigned to ‘EMP_NAME’ directly and not with a condition.
Ideally speaking, though the syntax is incorrect, this is what I’m trying to do:
[COLOR=RoyalBlue]_root.emp_name.text.gotoAndPlay(10); [/COLOR][COLOR=Green] //which is incorrect[/COLOR]
alternatively,
[COLOR=RoyalBlue]var instance_name = _root.holder.text;
_root.instance_name.gotoAndPlay(10);[/COLOR] [COLOR=Green]// which is also incorrect.[/COLOR]
So, is there a one liner code that would directly play the corresponding movie clip once after having read its instance name from the dynamic text field, WITHOUT a conditional statement?
Me make sense?