6 Replies Latest reply on Feb 5, 2013 9:12 PM by Rodan_Shiner

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

    Rodan_Shiner Level 1

      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.

        • 1. Re: I want to hide all layers other than one layer when I play swf at first.
          Ned Murphy Adobe Community Professional & MVP

          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. 

          1 person found this helpful
          • 2. Re: I want to hide all layers other than one layer when I play swf at first.
            Rodan_Shiner Level 1

            Thank you for your advice.

            I made a button and a layer for action script which  has a script

             

            _root.b_btn.onRelease = function():Void{

                      if(_root.b_mc._visible)

                      _root.b_mc._visible = false;

                      else if (!_root.b_mc.visible)

                      _root.b_mc._visible = true;

                      }

             

            _root.c_btn.onRelease = function():Void{

              if(_root.c_mc._visible)

              _root.c_mc._visible = false;

              else if (!_root.c_mc.visible)

              _root.c_mc._visible = true;

              }

             

             

            It works. They can toggle the visibility of Layer B and C, but it does not hide  B and C at first. When I load the swf file, it shows Layer A, B and C.All layers are displayed. I want to keep hiding B and C unless I click Button B and C.  What should I do to fix the problem?

            • 3. Re: I want to hide all layers other than one layer when I play swf at first.
              Ned Murphy Adobe Community Professional & MVP

              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.... 

               

              if(c_mc._visible){ 

                    c_mc._visible = false;

              } else {

                    c_mc._visible = true;

              }

              1 person found this helpful
              • 4. Re: I want to hide all layers other than one layer when I play swf at first.
                Rodan_Shiner Level 1

                Thank you for your advice.  I really don't know script rules. Thank you.

                And as for your script, it hides and shows the b_mc and c_mc but they cannot keep own visibility setting.. .Can I keep the visibility setting, say when I push a button to show them, I want to keep them displayed, right now they get invisible again when b and  c mc reach their end of frames.

                 

                I should have explained what I want to do in detail.

                a_mc , b_mc and c_mc are all loop movies. They are all 80 frames long. I want to play them all the time, but I want to control their visibility.

                I need to sync a_mc and b_mc and c_mc so I want to keep b_mc and c_mc playing when they are hidden. I mean when a man on a_mc goes forward, I need people on b_mc and c_mc to go forward, when a man on a_mc goes backward, I need people on b_mc and c_mc go backward.

                 

                What code should I use to keep their visibility?

                This is the situation. I want to keep them displayed If I push the button, but they get invisible as soon as the clip reach its end.

                 

                • 5. Re: I want to hide all layers other than one layer when I play swf at first.
                  Ned Murphy Adobe Community Professional & MVP

                  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? 

                  1 person found this helpful
                  • 6. Re: I want to hide all layers other than one layer when I play swf at first.
                    Rodan_Shiner Level 1

                    It's so hard to explain in English which is not my mother tongue. Sorry.

                     

                    http://www.dotup.org/uploda/www.dotup.org3917096.fla

                     

                    This is the fla file. I made that youtube movie from this fla.

                    Please test it. When I click b_btn and c_btn(pink buttons) ,those hide b_mc and c_mc, and  I want to loop both clips, but when b_mc and c_mc start to loop, they get invisible. I think

                     

                    b_mc._visible = false;

                    c_mc._visible = false;

                     

                    This code hides them again. Or did I something wrong? Please tell me why they get invisible.And I don't use other code to move my movie clips.

                    a_mc, b_mc and c_mc, all have a PNG sequence, which I made using PS and AE.