13 Replies Latest reply on Aug 31, 2007 9:39 PM by kglad

    Show and Hide content on stage with button action

    Ricky2k7 Level 1
      hi...

      I created a button to show and hide some content on stage. The button works well, but there's a problem...when i click on the button to show the content and i move to another section of the timeline the content hides again, and i just want it to hide when the button is clicked again :-(

      Here's my code:
        • 1. Re: Show and Hide content on stage with button action
          kglad Adobe Community Professional & MVP
          that "content" needs to exist on all your timeline frames where you want it to be visible. so, extend the layer's timeline that contains your "content".
          • 2. Re: Show and Hide content on stage with button action
            Ricky2k7 Level 1
            hi kglad

            The content that i want to use is already extended throughout the timeline :-(

            Two things usually happen:
            1) i apply the _root.acessibilidade._alpha = 0; in all the sections on the movie, and when i press the button to show the content it will be visible but when i go to another section it will disappear. Obvious!
            2)i only apply the _root.acessibilidade._alpha = 0; in the first frame of the movie, and when i go to another section the content will be visible when i don't want it to be :-(

            i've tried to apply the inicial values in a single layer and extend it to through the timeline and still it doesn't work properly.
            • 3. Re: Show and Hide content on stage with button action
              myckelh
              Try using _visible
              I belive you have to have your content within a MC

              _root.acessibilidade._visible=true
              _root.acessibilidade._visible=false
              • 4. Re: Show and Hide content on stage with button action
                kglad Adobe Community Professional & MVP
                if you assign that _alpha to be zero in the first frame of some movie and that movieclip plays its first frame repeatedly, that _alpha will be reassigned to zero.
                • 5. Show and Hide content on stage with button action
                  Ricky2k7 Level 1
                  hi myckelh!

                  the content is already in a MC, and i tried with _visible but it doesn't work with it :-(

                  that's right kglad, and i've already checked that too.

                  I'm trying something new...
                  i added this code to all the sections in the timeline so that it would know if the content should be visible or not. But its not working either :-(

                  is here something wrong with the code?

                  • 6. Re: Show and Hide content on stage with button action
                    kglad Adobe Community Professional & MVP
                    there's nothing wrong with your code. it's a problem with your logic.

                    you're re-assigning that _alpha to zero with code somewhere. i'm not sure what you mean by "..i've already checked that too"?

                    you're making apparently contradictory statements so it's hard to know what you've really done and what's incorrect.

                    and you talk about "the timeline" like there's only one timeline under discussion. is that true? is there only one timeline that contains code relevant to this issue?
                    • 7. Re: Show and Hide content on stage with button action
                      Ricky2k7 Level 1
                      sorry...
                      i'm a bit stressed out with this.

                      ok, first of all i have only one scene, and when i refer my self to the timeline, i'm talking about the total 1260 frames of the movie. sorry if that isn't the correct way to say it

                      i've got several of layers, and i created a folder layer specifically for the special content that i'm working on now.
                      So, i've got a actions layer for that content, and a the layer which contains the content that is some text information in a MC.

                      I've already checked the main actions layer to see if there is something assigning the MC to _alpha = 0; and there is nothing.
                      To prove that, every time i run the movie and go to a different section the "content" appears.

                      in the content actions layer i have this initialization in the first frame:

                      btAcess = 0;

                      if(btAcess == 0)
                      {
                      _root.acessibilidade._alpha = 0;
                      } else {
                      _root.acessibilidade._alpha = 100;
                      }

                      then at the beginning of the first section to the last section of the movie, i have this code:

                      if(btAcess == 0)
                      {
                      _root.acessibilidade._alpha = 0;
                      } else {
                      _root.acessibilidade._alpha = 100;
                      }

                      finally i have this code for the trigger button:

                      on(release, keyPress "a")
                      {
                      if(btAcess == 0)
                      {
                      _root.acessibilidade._alpha = 100;
                      btAcess = 1;
                      }
                      else
                      {
                      _root.acessibilidade._alpha = 0;
                      btAcess = 0;
                      }
                      }

                      i'm from portugal and it's a little hard for me to explain myself, sorry once again.
                      • 8. Re: Show and Hide content on stage with button action
                        kglad Adobe Community Professional & MVP
                        what does, "..then at the beginning of the first section to the last section of the movie" mean?

                        and is your button a true button or movieclip button? if it's a movieclip button use _root.btAcess instead of btAcess and see if that solves your problem.
                        • 9. Re: Show and Hide content on stage with button action
                          Ricky2k7 Level 1
                          what i mean is, the code is in a keyframe at the beginning of the movie and it goes to the last frame of the movie.

                          but i think i found the problem... :-|
                          i used the MC with all the information i want, and then i placed the MC inside a mask. I did this because the information is different on every section, and a simple way to hide and show the information depending on the section was with a mask layer.
                          I removed the mask and now it works :-S

                          how is that possible!!!?!?!?!?!?
                          • 10. Re: Show and Hide content on stage with button action
                            kglad Adobe Community Professional & MVP
                            i have no idea what you're describing: the MC = the movieclip whose _alpha you're trying to control? and that movieclip is masked?

                            but your first sentence reveals a misunderstanding of the way flash works. code is only executed when the playhead enters the frame that contains the code. so, code in frame 1 is executed once if the playhead never returns to frame 1. it doesn't matter that the timeline containing the code extends to more frames or the end of a multi-frame timeline.
                            • 11. Re: Show and Hide content on stage with button action
                              Ricky2k7 Level 1
                              "i have no idea what you're describing: the MC = the movieclip whose _alpha you're trying to control? and that movieclip is masked?"

                              i'm having trouble explaining myself... check ou this .fla and see for your self what i trying to say about the mask:
                              http://www.rld-i.com/teste.fla
                              • 12. Re: Show and Hide content on stage with button action
                                Ricky2k7 Level 1
                                quote:

                                Originally posted by: kglad
                                and is your button a true button or movieclip button? if it's a movieclip button use _root.btAcess instead of btAcess and see if that solves your problem.


                                forget it! you were right, and the issue was really simple after all...
                                just needed to add _root to the btAcess variable :-S

                                thanks once again kglad for the patience and most important, the help ;-)