PDA

View Full Version : can't get _visible=false to work


Frank
07-15-2007, 07:22 PM
I have a some actionscript that I think should work but doesn't.


for(var mi=1; mi<9; mi++){
this["chanukah_menorah.candle_" + mi]._visible = false;
this["chanukah_menorah.light_" + mi]._visible = false;
}



If I for example replace "this["chanukah_menorah.candle_" + mi]" with
"chanukah_menorah.candle_1" thru "chanukah_menorah.candle_8" it will work fine. I know that it doesn't seem like a big deal but I need this to work.

candle_1 is a movie clip in chanukah_menorah which is also a movie clip.

_Aerospace_Eng_
07-15-2007, 08:22 PM
Why not this?
for(var mi=1; mi<9; mi++){
chanukah_menorah.candle_+mi._visible = false;
chanukah_menorah.light_+mi._visible = false;
}

Frank
07-15-2007, 10:54 PM
I can't use that because the "mi" part is a variable and you can't insert variables in to actionscript like that. I have done something similar in the past with images but it doesn't work in this case. I have tried.

Omnis
07-16-2007, 07:00 AM
Have you tried using the eval() function (http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00005702.html)


for(var mi=1; mi<9; mi++){
eval("chanukah_menorah.candle_" + mi)._visible = false;
eval("chanukah_menorah.light_" + mi)._visible = false;
}

I tested it in Flash 5 just to be sure :D

Frank
07-16-2007, 11:09 PM
Yup that worked great.


Thanks :thumbsup: