4 Replies Latest reply on Dec 31, 2009 11:44 AM by Napo Monasterio

    How do I make buttons below inactive/active when a movie clip is playing?

    Napo Monasterio Level 1

      Hi folks,

       

      Quick, simple question here. I've got an infographic I'm working on, and every time I roll over an image (a ring) the alpha goes up to 100, then I roll out and it goes back to 50. That much I'm good with.

       

      Then, I click on each one of them, and a movie clip (built inside of each ring/button) pops up and plays. Fair enough.

       

      I've got a script (ugly, but it works!) that will hide all other buttons while this movie clip is playing. But, when I click to close it, I can't figure out a way to make them reappear. I tried putting visible = true again for all of them, but no dice.

       

      The actionscript for it is right below.

       

      I'm not sure if there's anything I can do to make it modal in AS3 or something like that. Or should I go ahead and set it up in a parent/child kind of way (not too well-versed in that regard.

       

      All the buttons to click on are in the same layer — and I'm not sure if making them different layers in Flash would make any difference.

       

      Thoughts, anyone? Much obliged in advance!

       

      -----------------------

       

      stop();

       

      ring1926.movie1926.visible = false;

       

       

       

      // add a rollover to make the inside movieclip appear

       

      ring1926.addEventListener(MouseEvent.ROLL_OVER,onAlpha);

       

      function onAlpha(evt:MouseEvent):void {
         
          ring1926.alpha = 1

       

      }

       

      // add a rollover to make the inside movieclip appear

       

      ring1926.addEventListener(MouseEvent.ROLL_OUT, offAlpha);

       


      function offAlpha(evt:MouseEvent):void {
         
          ring1926.alpha = .5
         
      }

       

      ring1926.addEventListener(MouseEvent.CLICK, movie1926);

       


      function movie1926(evt:MouseEvent):void {
         
          ring1926.movie1926.visible = !ring1926.movie1926.visible;
          ring1926.alpha = 1
          ring1926.movie1926.alpha = 1
          ring1927.visible = false
          ring1931.visible = false
          ring1935.visible = false
          ring1942.visible = false
          ring1961.visible = false
          ring1964.visible = false
          ring1965.visible = false
          ring1973.visible = false
          ring1978.visible = false
          ring1979.visible = false
          ring1992.visible = false
         
      }

       

      ring1926.movie1926.closebutton1926.addEventListener(MouseEvent.CLICK, closebutton1926);

       


      function closebutton1926(evt:MouseEvent):void {
         
          ring1926.movie1926.visible = false;
          ring1926.visible = true
          ring1927.visible = true
          ring1931.visible = true
          ring1935.visible = true
          ring1942.visible = true
          ring1961.visible = true
          ring1964.visible = true
          ring1965.visible = true
          ring1973.visible = true
          ring1978.visible = true
          ring1979.visible = true
          ring1992.visible = true
         
      }

        • 1. Re: How do I make buttons below inactive/active when a movie clip is playing?
          Ned Murphy Adobe Community Professional & MVP

          If you change the visible property to false, then setting it to true again should restore things, so I don't know what might be going wrong there.

           

          I get a sense that the code you show is recreated for each ring object.  You may do yourself a favor by creating two functions that manipulate all of the objects visible property so that you do not have to repeat all of that code for each instance.  Just trun them all visible/invisible first, then do the special actions for the selected button only.

          • 2. Re: How do I make buttons below inactive/active when a movie clip is playing?
            Napo Monasterio Level 1

            Thanks for the prompt reply, Ned!

             

            OK, testing now...

             

            So, basically, I'm going to do something that toggles the visible and invisible, then worry about the rest. Let me see what shakes out.

            • 3. Re: How do I make buttons below inactive/active when a movie clip is playing?
              Napo Monasterio Level 1

              Hmmm... No luck yet.

               

              I'm also getting this error message: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                  at 2009Alabamafootballnationalchampionship3_fla::MainTimeline/frame1()

               

              If I do this coding, I can neither hide nor show back.

               

              ------------

               

              stop();

               

              ring1926.movie1926.visible = false;

               

               

               

              // add a rollover to make the inside movieclip appear

               

              ring1926.addEventListener(MouseEvent.ROLL_OVER,onAlpha);

               

              function onAlpha(evt:MouseEvent):void {
                 
                  ring1926.alpha = 1

               

              }

               

              // add a rollover to make the inside movieclip appear

               

              ring1926.addEventListener(MouseEvent.ROLL_OUT, offAlpha);

               


              function offAlpha(evt:MouseEvent):void {
                 
                  ring1926.alpha = .5
                 
              }

               

              ring1926.addEventListener(MouseEvent.CLICK, movie1926);

               


              function movie1926(evt:MouseEvent):void {

               

                  ring1927.visible = false
                  ring1931.visible = false
                  ring1935.visible = false
                  ring1942.visible = false
                  ring1961.visible = false
                  ring1964.visible = false
                  ring1965.visible = false
                  ring1973.visible = false
                  ring1978.visible = false
                  ring1979.visible = false
                  ring1992.visible = false
                 
              }

               

               

               

              ring1926.addEventListener(MouseEvent.CLICK, closemovie1926);

               

                 
              function closemovie1926(evt:MouseEvent):void {
                 
                  ring1926.visible = true
                  ring1927.visible = true
                  ring1931.visible = true
                  ring1935.visible = true
                  ring1942.visible = true
                  ring1961.visible = true
                  ring1964.visible = true
                  ring1965.visible = true
                  ring1973.visible = true
                  ring1978.visible = true
                  ring1979.visible = true
                  ring1992.visible = true
                 
              }

               

               

              --------------

               

              If I use this, it will play the movie, hide the rest, then I can hide the movie, yet I can't show the rings again.

               

              ----------------

               

              stop();

               

              ring1926.movie1926.visible = false;

               

               

               

              // add a rollover to make the inside movieclip appear

               

              ring1926.addEventListener(MouseEvent.ROLL_OVER,onAlpha);

               

              function onAlpha(evt:MouseEvent):void {
                 
                  ring1926.alpha = 1

               

              }

               

              // add a rollover to make the inside movieclip appear

               

              ring1926.addEventListener(MouseEvent.ROLL_OUT, offAlpha);

               


              function offAlpha(evt:MouseEvent):void {
                 
                  ring1926.alpha = .5
                 
              }

               

              ring1926.addEventListener(MouseEvent.CLICK, movie1926);

               


              function movie1926(evt:MouseEvent):void {

               

                  ring1927.visible = false
                  ring1931.visible = false
                  ring1935.visible = false
                  ring1942.visible = false
                  ring1961.visible = false
                  ring1964.visible = false
                  ring1965.visible = false
                  ring1973.visible = false
                  ring1978.visible = false
                  ring1979.visible = false
                  ring1992.visible = false
                 
              }
                 
              ring1926.addEventListener(MouseEvent.CLICK, playmovie1926);

               

                 
              function playmovie1926(evt:MouseEvent):void {
                 
                  ring1926.movie1926.visible = !ring1926.movie1926.visible;
                  ring1926.movie1926.alpha = 1
                 
              }

               

              ring1926.movie1926.closebutton1926.addEventListener(MouseEvent.CLICK, closemovie1926);

               

                 
              function closemovie1926(evt:MouseEvent):void {
                 
                  ring1926.movie1926.visible = !ring1926.movie1926.visible;
                  ring1927.visible = true
                  ring1931.visible = true
                  ring1935.visible = true
                  ring1942.visible = true
                  ring1961.visible = true
                  ring1964.visible = true
                  ring1965.visible = true
                  ring1973.visible = true
                  ring1978.visible = true
                  ring1979.visible = true
                  ring1992.visible = true
                 
              }

               

               

              --------

              • 4. Re: How do I make buttons below inactive/active when a movie clip is playing?
                Napo Monasterio Level 1

                Hey, I think I fixed! Dang, that's a good way to end up the year!

                 

                Now all I need to do is hope that the other 11 objects play nice...

                 

                Here's the coding, for what it's worth...

                 

                -----

                 

                stop();

                 

                ring1926.visible = true;
                ring1927.visible = true;
                ring1931.visible = true;
                ring1935.visible = true;
                ring1942.visible = true;
                ring1961.visible = true;
                ring1964.visible = true;
                ring1965.visible = true;
                ring1973.visible = true;
                ring1978.visible = true;
                ring1979.visible = true;
                ring1992.visible = true;
                ring1926.movie1926.visible = false;

                 

                 

                 

                // add a rollover to make the inside movieclip appear

                 

                ring1926.addEventListener(MouseEvent.ROLL_OVER,onAlpha);

                 

                function onAlpha(evt:MouseEvent):void {
                   
                    ring1926.alpha = 1

                 

                }

                 

                // add a rollover to make the inside movieclip appear

                 

                ring1926.addEventListener(MouseEvent.ROLL_OUT, offAlpha);

                 


                function offAlpha(evt:MouseEvent):void {
                   
                    ring1926.alpha = .5
                   
                }

                 

                ring1926.addEventListener(MouseEvent.CLICK, showhide1926);

                 


                function showhide1926(evt:MouseEvent):void {
                   
                    ring1927.visible = !ring1927.visible;
                    ring1931.visible = !ring1931.visible;
                    ring1935.visible = !ring1935.visible;
                    ring1942.visible = !ring1942.visible;
                    ring1961.visible = !ring1961.visible;
                    ring1964.visible = !ring1964.visible;
                    ring1965.visible = !ring1965.visible;
                    ring1973.visible = !ring1973.visible;
                    ring1978.visible = !ring1978.visible;
                    ring1979.visible = !ring1979.visible;
                    ring1992.visible = !ring1992.visible;

                 

                }

                 


                ring1926.addEventListener(MouseEvent.CLICK, movie1926);

                 


                function movie1926(evt:MouseEvent):void {
                   
                    ring1926.movie1926.visible = !ring1926.movie1926.visible;
                    ring1926.alpha = 1
                    ring1926.movie1926.alpha = 1
                   
                }

                 


                -----