Skip to main content
Participant
November 13, 2008
Question

How to make layers visible/invisible

  • November 13, 2008
  • 2 replies
  • 4299 views
We have a flash project, and it is related to some modifications of the text.
Unfortunately, I'm not working only for myself, I'm just a coder. Designer prepared all the staff, everything in MC as needed, but inside movieClips there are more than 10 layers, and sometimes not all of them needed to be shown.
Unfortunately, objects in that movieClips are just drawings.
Because, there are hundreds of that staff, is it possible to make the total layer invisible/visible programmatically?
("make everything mc" is not a solution 😞 )
Digging in help, found this:
The following example makes all objects in the first layer invisible:
fl.getDocumentDOM().getTimeline().layers[0].visible = false;
but it is working only in mx version. Need something similar in as3 or at least as2.
This topic has been closed for replies.

2 replies

Ned Murphy
Legend
November 14, 2008
I was intrigued enough to do a little searching, but couldn't find anything along the lines of what you're trying to do. I did find a file "hide_layer.fla" but it turned out to be a rather simple approach for the nearly 700KB file size it is... but maybe it could work for you...

Place a mask layer over the layer you want to hide. In that layer have a mask movieclip with two frames... one has a stage sized rectangle for when you want the layer to show, the other has nothing. So you switch the mask between the two frames as needed. The only problem I short-sightedly foresee at the moment is that any dynamic text fields will have to have their fonts embedded.

nDaniLAuthor
Participant
November 14, 2008
Thank you for a solution, indeed it is.
another solution to it making them movie clips.
But, because there are too many of them,(hundreds) I need to make many changes, what i don't want to do.
Every movieclip of a special character has approximately 10 layers, named and ordered the same way.
I don't want to modify the movieclip itself. I want to hide some of them by using code.
Inspiring
November 14, 2008
Well if you need to control the visibility for some places and not in others and you are using AS2 your only solution is to make them MovieClips. There is no other solution. (period)

The code you have shown is JavaScript for flash and it will only work in the authoring environment. It will not work in the published document. The JSFL just automates things you can do by hand. It is the same as going in and clicking the little dot under the eye to hide the layer.

A better idea could be to make those layers into a guide layer and then its contents won't publish. But if you need one instance of the clip with the layer on and one instance with it off that won't help either.

You could duplicate the whole clips and then remove the layers from the new symbols that don't need them. But then if there are changes it will get to be pretty awful.

But really the only answer is to make things in MCs. Really.