• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

AS2 name passing

I am updating multiple calls from hard-coding to a function, passing a variable

var th:String = "round";
var thMask = thSh+"mask";
thisBox.attachMovie(thMask,thMask,70);

The above works as expected. The following is what I have when hard coded:
//gCollisionMask = _level0.workBox.roundmask;

However, I want to pass the value using the following code (which is not correct):
gCollisionMask = _level0.workBox.thMask;

Ican't remember what it should be - should there be brackets around part of it?
0
msukow
Asked:
msukow
1 Solution
 
phodges4Commented:
you can use eval if you want:

gCollisionMask = eval("_level0.workBox." + thMask);
0
 
msukowAuthor Commented:
I also found this works:
gCollisionMask = _level0.workBox[thMask];
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now