PDA

View Full Version : Simple array - what's wrong?


mtran
01-19-2007, 08:49 AM
I have a bunch of buttons, and want to set the visibility off for all initially. All btn are on stage and named accordingly.

I put all in an array, but perhaps my loop didn't work. What's wrong?

menu_array = new Array("dinner_btn","lunch_btn","wine_btn","rollmenu_btn");
for (i=0; i<menu_array.length; i++){
menu_array[i]._visible = false;}


I trace menu_array and it displays the list ok.

CyanBlue
01-19-2007, 02:23 PM
Howdy and Welcome... ;)

If you say "some_btn", Flash considers it as a string... and there is no property called _visible for the string... Know what I mean???
So, what you need to do is to remove the double quotes around the button instance names in line 1...

3pepe3
01-21-2007, 01:32 AM
hi cyanblue... i don't agree with you that he must remove the quotes but yes now what he is doing is set _visible to the string.
i think the problem will be fixed with:

this[menu_array[i]]._visible = false;
trace(this[menu_array[0]])///>>>_level0.dinner_btn
trace(menu_array[0])////>>>>dinner_btn (string)
}