*movie clip visible with variable*

var currentComponent = "firewall";
trace (currentComponent);
_root.currentComponent._visible = false;

why can I not use a variable for the instance name?
LVL 1
gmailrulesAsked:
Who is Participating?
 
muso120999Connect With a Mentor Commented:
Because it's a string, not a movieclip object.  However, you can reference an object by using a string like:

 var currentComponent = "firewall";
trace (currentComponent);
_root[currentComponent]._visible = false;
0
 
muso120999Commented:
Another note:

the square brackets enable you to reference anything by:
container[propertyName];

and you can even call a function by:
var functionName = "myFunction";
_root[functionName]();

- the () indicate to Flash that it is a function.
0
 
gmailrulesAuthor Commented:
Thanks once again Muso :)
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
muso120999Commented:
Glad to help :-)

btw does gmail really "rule" then!?
0
 
gmailrulesAuthor Commented:
yeah, you want an invite?
0
 
muso120999Commented:
Sure, interested.  What's involved?
0
 
gmailrulesAuthor Commented:
just tell me your email and I send you an invite, and you make a free gmail account.
0
 
muso120999Commented:
muso <at> fusionsite.co.uk

thanks :-)
0
 
gmailrulesAuthor Commented:
sent!
0
All Courses

From novice to tech pro — start learning today.