# Changing the Visibility of Layers

**URL:** <https://forum.kirupa.com/t/changing-the-visibility-of-layers/1964>\
**Category:** flash\
**Created:** [April 12, 2002, 8:39am UTC](https://forum.kirupa.com/t/changing-the-visibility-of-layers/1964 "2002-04-12T08:39:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 12, 2002, 8:39am UTC](https://forum.kirupa.com/t/changing-the-visibility-of-layers/1964/1 "2002-04-12T08:39:06Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 12, 2002, 8:59am UTC](https://forum.kirupa.com/t/changing-the-visibility-of-layers/1964/2 "2002-04-12T08:59:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 12, 2002, 9:29am UTC](https://forum.kirupa.com/t/changing-the-visibility-of-layers/1964/3 "2002-04-12T09:29:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 12, 2002, 9:51am UTC](https://forum.kirupa.com/t/changing-the-visibility-of-layers/1964/4 "2002-04-12T09:51:05Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 12, 2002, 10:05am UTC](https://forum.kirupa.com/t/changing-the-visibility-of-layers/1964/5 "2002-04-12T10:05:48Z")

</div>

🙂 … glad it’s working for ya
