6 Replies Latest reply on Jul 16, 2011 4:45 AM by Ned Murphy

    Buttons and Movie Clips (on and off)

    ennzzo55

      I'm working on my own personal website for my graphic design work and I'm using flash for the intro movie, which you can either skip or after an elapsed time, sends you directly to the home page.

       

      On that intro movie (which ill call animatedface_mc) i've put two other movie clips with the eyes blinking (left and right). The eyes would be constantly blinking, as this page is open. That one is working.

       

      Off to the side are buttons of names of famous celebrities and once clicked it adds movie clips to the main animatedface_mc. For example if i clicked on the monroe_mc, it adds that famous Marilyn Monroe mole (using either mask or opacity, depending on the facial feature) on the animatedface_mc. If I clicked on tyson_mc, it adds his face tattoo. I've used the following code for this:

      monroe_btn.addEventListener(MouseEvent.CLICK, monroeshow);
      function monroeshow (event:MouseEvent){
           monroe_mc.play();   
      }

      tyson_btn.addEventListener(MouseEvent.CLICK, tysonshow);
      function tysonshow (event:MouseEvent){
          tyson_mc.play();
      }

       

      There are atleast 10 other buttons on that page but i've come to realize that some of the facial features are over-lapping and thus, does not look good. I was wondering if there was a way that when you clicked on one button, it turns off movie clips that are already turned on, so if maybe tyson_mc and chaplin_mc were already on, and I clicked on monroe_btn, monroe_mc shows up,  and tyson / chaplin movie clips would be turned off. The tyson and chaplin buttons would still be clickable, just that their movie clips, if already on, would be turned off.

       

      I've tried the following but it doesn't seem to work: tyson_mc.enabled=false;

       

      Thanks in advance for the help.

        • 1. Re: Buttons and Movie Clips (on and off)
          Ned Murphy Adobe Community Professional & MVP

          One way to do this is to have a reset function that makes all animations return to some state (go to frame 1 in your case I would guess).  And follow that with telling the object related to the clicked button to start playing. So each time you click a button the current animation (or animations) is removed first, then the clicked one starts.

          1 person found this helpful
          • 2. Re: Buttons and Movie Clips (on and off)
            Ned Murphy Adobe Community Professional & MVP

            Also, if you just want them to disappear, set their visible property to false... tyson_mc.visible=false;

            1 person found this helpful
            • 3. Re: Buttons and Movie Clips (on and off)
              ennzzo55 Level 1

              Thank you so much for the quick reply.

               

              I tried the tyson_mc.visible=false; script

              so for every button, i put the movie clips of the other buttons to false? but once one button is clicked, none of the movie clips would be showing after that initial click. so it would only work on that that first click.

               

              I'm very much a novice when it comes to flash so please help me out with your first suggestion.

               

              so currently on scene 1, all i have are 3 layers, a layer for the movie clips, a layer for buttons and a layer for actions. all 3 layers only have one frame. so should i be moving the buttons layer, the actions layer and the movie clips (with the exception of the animatedface_mc) to frame 2? And what do i add on the actions script? gotoAndPlay(1); or is there more to the script?

               

              Also I have it so the user, if he chooses could stop the character from blinking or have it start blinking again. and so i have it go back to frame 1:

                  animatedface_mc.animatedeyeright_mc.gotoAndStop(1);
                  animatedface_mc.animatedeyeleft_mc.gotoAndStop(1);

              or

                  animatedface_mc.animatedeyeright_mc.gotoAndPlay(1);
                  animatedface_mc.animatedeyeleft_mc.gotoAndPlay(1);

               

              is that not gonna work now?

               

              Thanks again. Very much appreciated.

              • 4. Re: Buttons and Movie Clips (on and off)
                Ned Murphy Adobe Community Professional & MVP

                You don't need to have a frame 2 on the main timeline if you have everything in frame 1 now.  You can use tyson_mc.visible = true;  when the tyson button is clicked so that if it was previously made invisible, it will become visible again.

                 

                This would be the basic series of comands that clicking a button could produce...

                 

                function resetMCs(){      // shared by all buttons

                     monroe_mc.gotoAndStop(1);    // or monroe_mc.visible = false;

                     tyson_mc.gotoAndStop(1);       // or tyson_mc.visible = false;

                }

                 

                monroe_btn.addEventListener(MouseEvent.CLICK, monroeshow);
                function monroeshow (event:MouseEvent){

                    resetMCs();

                    monroe_mc.visible = true;

                    monroe_mc.play();    // see comments at bottom
                }

                 

                tyson_btn.addEventListener(MouseEvent.CLICK, tysonshow);
                function tysonshow (event:MouseEvent){

                    resetMCs();

                    tyson_mc.visible = true;
                    tyson_mc.play();       // see comments at bottom

                }

                 

                If the mole and tatoo movies don't really animate at all and telling them to play just makes them appear, then you could do away with multiple frames for them and just control their visibility instead of telling them to play.

                • 5. Re: Buttons and Movie Clips (on and off)
                  ennzzo55 Level 1

                  You're awesome man! Worked perfectly! Thanks so much.

                  • 6. Re: Buttons and Movie Clips (on and off)
                    Ned Murphy Adobe Community Professional & MVP

                    You're welcome