views:

17

answers:

1

i'm getting a value from a class that gives me e.g "icon1" as data. i want to use this within a function to control the visibility of an item nested in a movieclip on the stage. the nested movie has the same name as the data being sent.

// here's what i want it to do: mymenu.icon1.visible = true;

// but i cant append the 2 together as flash will see it as a string not read it as path. e.g function (iconreceived){

mymenu.iconreceived.viaible = true; } any clues?

+1  A: 

Use brackets. Since thing1.thing2 is the same as thing1["thing2"]:

function setIconVisible(iconReceived:String): void {    
    mymenu[iconReceived].visible = true;
}

It's usually not a good idea to have string/name-based references, but the above works.

zeh