5 Replies Latest reply on May 31, 2011 4:51 PM by Ned Murphy

    Keeping mc visibility consistant

    learner102

      Hi,

      I am working on part of an Escape Game using AS2 - Flash8.  I am doing navigation where clicking the mc sets it's visibility to "false" and a previously unseen button's visibility to "true".  You click the button and are sent to another room on the next frame.  But when you return to the first room the mc is visible again and the button invisible.  The room is basically reset.  I do not know how to keep the mc in a state of _visible=false;  Thanks for any help.

       

      Kim

        • 1. Re: Keeping mc visibility consistant
          Ned Murphy Adobe Community Professional & MVP

          Keep the button and the mc in both frames and don't have any code that resets them.

          • 2. Re: Keeping mc visibility consistant
            learner102 Level 1

            I am not sure how that helps because navigation in all the rooms are completely different.  I have read about setting up a _global var.  Would that help?  If so i do not know the correct way to set it up.  Here is the simple script on the AS frame:

             

            stop();

            hole1_mc._visible=false;

            holeCover1_mc.onRelease=function(){
              hole1_mc._visible=true;
            holeCover1_mc._visible=false;
            }

             

            But leaving the room and coming back resets it as you know.  Can you explain your idea a little more clearly?  Thank you.

            • 3. Re: Keeping mc visibility consistant
              Ned Murphy Adobe Community Professional & MVP

              If  the button cannot be kept visible in the other frames, then using variables to set the visibility will work as an alternative.  They don't need to be _global, but they will need to be declared on a layer that extends the full length of the timeline so that the _visible status will remain in effect.  Then only change that value when conditions call for it.

               

              So create a layer for these variables that extends the length of the timeline and declare them in frame 1 and then conditionally assign their initial values...

               

              var h1Visible;

              var hc1Visible;

               

              if(h1Visible == undefined) h1Visible = false;

              if(hc1Visible == undefined) hc1Visible = true;

               

              What that does is make it so that the first time thru that frame the values are set to true/false as shown, but when that frame is returned to, they are no longer undefined, so they will retail whatever value they had.

               

              So then what you do is assign them to the objects in the frames wherever else in the timeline where you need to...

               

              stop();

               

              hole1_mc._visible=h1Visible;

              holeCover1_mc._visible=hc1Visible;

              holeCover1_mc.onRelease=function(){
                  h1Visible = true;

                  hole1_mc._visible=true;

                  hc1Visible = false;
                  holeCover1_mc._visible=hc1Visible;
              }

              • 4. Re: Keeping mc visibility consistant
                learner102 Level 1

                That worked, Thank you soooo much!

                • 5. Re: Keeping mc visibility consistant
                  Ned Murphy Adobe Community Professional & MVP

                  I missed changing one line in that  last bit of code.  I have bolded it below...

                   

                  hole1_mc._visible=h1Visible;

                  holeCover1_mc._visible=hc1Visible;

                  holeCover1_mc.onRelease=function(){
                      h1Visible = true;

                     hole1_mc._visible=h1Visible;

                      hc1Visible = false;
                      holeCover1_mc._visible=hc1Visible;
                  }

                   

                   

                   

                   

                   

                  1 person found this helpful