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?
msukowAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
phodges4Connect With a Mentor Commented:
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.

All Courses

From novice to tech pro — start learning today.