Solved

*movie clip visible with variable*

Posted on 2004-10-07
9
268 Views
Last Modified: 2008-02-01
var currentComponent = "firewall";
trace (currentComponent);
_root.currentComponent._visible = false;

why can I not use a variable for the instance name?
0
Comment
Question by:gmailrules
  • 5
  • 4
9 Comments
 
LVL 10

Accepted Solution

by:
muso120999 earned 500 total points
ID: 12252847
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
 
LVL 10

Expert Comment

by:muso120999
ID: 12252877
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
 
LVL 1

Author Comment

by:gmailrules
ID: 12252904
Thanks once again Muso :)
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 10

Expert Comment

by:muso120999
ID: 12252925
Glad to help :-)

btw does gmail really "rule" then!?
0
 
LVL 1

Author Comment

by:gmailrules
ID: 12252935
yeah, you want an invite?
0
 
LVL 10

Expert Comment

by:muso120999
ID: 12252950
Sure, interested.  What's involved?
0
 
LVL 1

Author Comment

by:gmailrules
ID: 12252971
just tell me your email and I send you an invite, and you make a free gmail account.
0
 
LVL 10

Expert Comment

by:muso120999
ID: 12252990
muso <at> fusionsite.co.uk

thanks :-)
0
 
LVL 1

Author Comment

by:gmailrules
ID: 12253027
sent!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question