Changing the Visibility of Layers

Hey, in MX using actionscript, how do you set the visibility of a layer?
I have three layers that i want to be swapping between visible and invisible.

basically i think the algorithm is:

onMouseDown
set Visibility of Layer One to False
set Visibility of Layer Two to True
Set Visibility of Layer Three to False
end

Thanks!

There are two ways. If what is on the layer is a symbol, and it has a keyframe, you can select that frame, then select the object on the stage, and then using the effects panel, you can set the _alpha with that.

Sometimes, like if you have a tween where you want it to go from 100% to 0% visiblility, this is the way to do it.

The other way is this. It’s a little more complex, but it’s the prefered method for file size.

Copy the frames from one of the layer.
Use menu option “Insert/Create new symbol” to bring up the new symbol dialogue.
Choose “movie clip” and give it a library name that is discriptive.
Go into the library and double click on it to edit it. Paste the frames in this symbol.

Do this with each of the three layers in each of their own movie clips.

you can now cut the frames out of the layers on your main timeline. From the library, drag instances of each of the three movie clips to the stage, in one layer or in three… it really doesn’t matter.

Now select each movie clip and in turn, give each an “Instance” name in the properties panel. (If you have a movie clip selected, you will see the text field there for entering an instance name… labeled with <instance>.)

Now, you can call to each symbol as you like. For instance, if you wanted a symbol to be invisible, and for any button inside it to be disabled you could use this command

_root.theNameOfMyMovieClip._visible=false;

or you could set the _alpha (which does not deactivate buttons within the movie clip), with this command

_root.theNameOfMyMovieClip._alpha=0%;

I find this latter method to work best for me, but it’s really personal choice.

For the record, “_visible=false;” saves processor speed over “_alpha=0;”… so if you’ve got a lot moving on the stage at once, and things are slowing down, it’s good to think about either removing movie clips, or making them _visble=false;

Hope that helped.

Yeah thanks thats got me started!!

So now I want to be able to control the visibility so when you click on a button, it changes the visibility of, say, tab two to true and sets the other tabs to false.

oh wait! ive done it myself
for those that are interested:

For each of the buttons I put this on:

on (release) {
&nbsp &nbsp &nbsp &nbsp setProperty(tabone, _visible, true);
&nbsp &nbsp &nbsp &nbsp setProperty(tabtwo, _visible, false);
&nbsp &nbsp &nbsp &nbsp setProperty(tabthree, _visible, false);
}

Booyah!

:slight_smile: … glad it’s working for ya