View Full Version : Hiding layers with actionscript

12 December 2002, 08:47 PM
hey there boys...
i was wondering if there was a way to hide a whole layer with actionscript instead of doing a setProperty(target,_visible,false) for all the object of each layers....this would make a huge difference in my would save me lotsa time...

12 December 2002, 09:06 PM
i don't think you can hide layers. but you could:

a) mask your layer and change the mask, if you want to hide the layer

b) put all movieclips in another big movieclip and hide this one.

if you use flash 5 or mx, use this syntax:
movieclip._visible = false;

12 December 2002, 09:14 PM
dunno... but you could fake it by haveing a variable for each layer (or an array) with a true/flase value in the root level. then make each movie clip check (you could copy and paste the same code between the movie clips, or do it as you make them, something in the enterFrame state should do it along tthe lines of

if (_root.myvariable) {_visible=false;}else{_visible=true};

then just substitute "myvariable" with the variable or array in the root level.

alternatively you can use _level0._visible (to control the root level stuff, then _level1._visible etc... though it doesn't work in a really comfortable way

you can also address multiple movie clips with teh same name but different numbers usinf for statements provided you make everything the right syntax e.g.

for (i=0;i<10;i++) {

(at least if my memory serves me right this is how it works... but i could be wrong, the syntax may be slightly different on the second line... it's not something covered in any of the flash manuals (rather stupid to not cover that i feel... but then macromedia manuals are some of the worst in the known universe).

hope this helps

12 December 2002, 10:08 PM
another cheezy quick and dirty trick i've learned to accomplish something similar is to simply have a blank keyframe with a stop action on frame 1, then a "gotoAndStop(2)" action where appropriate. effectively "hides" any layers/objects/etc. that are needed.


CGTalk Moderation
01 January 2006, 02:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.