Skip navigation
Currently Being Moderated

I want to hide all layers other than one layer when I play swf at first.

Feb 4, 2013 8:00 AM

Tags: #adobe_flash_pro

Hello. I am using Adobe Flash CS6 and AC2.

Right now I am trying to hide all layers other than one layer. There are 3 layers on my fla file like this.


Layer A

Layer B

Layer C


I want to keep hiding  Layers B and C unless  I click a button that makes layer B and C visible.

Layer A has a movie clip symbol, and it contains animation movie where a man  is running.

And Layer B and C has a movie clip where people  are chasing the person who is running on Layer A.

I mean, if I load swf file at first, there is only one person who is running, and when I click a button two people appears on a stage and they start to chase the person who is running on layer A.


What kind of script should I use to make this setting? Please give me your advice.

Thank you in advance.

  • Currently Being Moderated
    Feb 4, 2013 8:10 AM   in reply to Rodan_Shiner

    It partly depends on how your running animations are made, but the layers will have nothing to do with having things hidden if the objective is to use code to make things visible.  Layers can only be hidden as part of the IDE for testing where you turn the layer into a guide layer so that it does not appear when you run the file.  BUt you say you want the objects to be able to hide/show while running the file.


    If you are using AS2, then you can control the _visible property of the objects by setting them to be true or false. 

    Mark as:
  • Currently Being Moderated
    Feb 5, 2013 4:31 AM   in reply to Rodan_Shiner

    Here is a simplified version of the code, including the two lines needed to make them invisible at the start....


    b_mc._visible = false;

    c_mc._visible = false;


    b_btn.onRelease = function():Void{

              b_mc._visible = !b_mc._visible;



    c_btn.onRelease = function():Void{

             c_mc._visible = !c_mc._visible;



    What that version of the coding does is simply tell the object to acquire the opposite ( ! ) value of the current _visible property.


    Notice also that I have removed the "_root " references inm the code.  You should not make a habit of using it unnecessarily.  If the code is in the main timeline already (the _root), there is no need to target it, and doing so can lead to problems if you ever need to load this file into another.  If that code is not in the _root timeline then it is okay to use _root, though using "_parent " references can be safer for the same reason.



    The way you had the code written is not wrong, but it was excessive in that you do not have to test the condition twice like you did, if it is not true then it has to be false.... 



          c_mc._visible = false;

    } else {

          c_mc._visible = true;


    Mark as:
  • Currently Being Moderated
    Feb 5, 2013 7:52 PM   in reply to Rodan_Shiner

    They should not become invisible when they reach their end frames unless you do something that makes them invisible... whatever that is you have not explained it.


    I have no idea what that video you planted is trying to show


    As far as making things go forward or backward together, what controls do you have in place for that? 

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points