6 Replies Latest reply on Feb 19, 2011 5:48 AM by Ned Murphy

    Need some help with simple flash buttons

    Aiguchi

      So I need either some direct tutorial help or for someone to point me in the direction of something helpful.

       

      What I am trying to do is create 3 clickable flash buttons which all link to a small box. I want these buttons to make some text appear in the box once clicked. I want the box to be blank until one button is clicked.

       

      EXAMPLE

       

      _______________
      | TEXT HERE       |
      |                          |
      |_______________|
      ___     ___     ___
      |__|     |__|     |___|

       

       

       

      Thanks a lot in advance.

        • 1. Re: Need some help with simple flash buttons
          Ned Murphy Adobe Community Professional & MVP

          What version of actionscript are you using?

          1 person found this helpful
          • 2. Re: Need some help with simple flash buttons
            Aiguchi Level 1

            I am using 3.0

             

            Just to let you know I am very new to all of this, I have almost finished the script now I just need some help touching it up.

             

            Basicly , I have imported 3 buttons made in photoshop, all turned into buttons and named.

             

            BTN1 , BTN2 , BTN3

             

            Frame 1 shows these 3 buttons on their own.

             

            Frame 2 shows the 3 buttons and the text for BTN1

             

            Frame 3 shows the 3 buttons and the text for  BTN2

             

            Frame 4 shows the 3 buttons and the text for BTN3

             

            However I just need some help coding them. Currently it doesn't really work.

             

            If you could tell me the coding that would work for each frame it would really help!!!!

             

            Heres what I have so far. Only for frame 1 I need it touching up and help for the other frames.

             

            stop();
            BTN1.addEventListener(MouseEvent.CLICK,mouseClick);
            function mouseClick(event:MouseEvent):void
            {
            gotoAndStop(2);
            }
            BTN2.addEventListener(MouseEvent.CLICK,mouseClick);
            {
            gotoAndStop(3);
            }
            BTN3.addEventListener(MouseEvent.CLICK,mouseClick);
            {
            gotoAndStop(4);
            }

            • 3. Re: Need some help with simple flash buttons
              Ned Murphy Adobe Community Professional & MVP

              What you described you have hints that you didn't set it up efficiently.

               

              Your buttons should be in their own layer and should only have a keyframe in frame 1.  Just extend them thru frame 4 by inserting a regular frame in frame 4 of that layer.  So you should only see a filled dot in frame 1 of that layer with shading thru frame 4.  The buttons in frame 1 will then be available in all those frames.  Each button should have its instance name assigned in the Properties panel--if those are just their library names, that won't work.

               

              Similarly, your code should only go in frame 1 and that layer can be similarly extended to frame 4.

               

              You could easily do this n just one frame if the only thing changing is the text in the textfield.  If you make the textfield a dynamic textfield you can have each button assign its text to the textfield when clicked.  Suppose you name the textfield tField...

               

              BTN1.addEventListener(MouseEvent.CLICK,mouseClick1);
              function mouseClick(event:MouseEvent):void
              {
                   tField.text = "text for btn 1";

              }

              BTN2.addEventListener(MouseEvent.CLICK,mouseClick2);

              function mouseClick2(event:MouseEvent):void
              {
                   tField.text = "text for btn 2";

              }

              BTN3.addEventListener(MouseEvent.CLICK,mouseClick3);

              function mouseClick3(event:MouseEvent):void
              {
                   tField.text = "text for btn 3";

              }

               

              Message was edited by: Ned Murphy - revised to correct code example (I hope)

              • 4. Re: Need some help with simple flash buttons
                Ned Murphy Adobe Community Professional & MVP

                Strike what I said regarding the code being fine.  It isn't (my eyes just woke up).  Below is a proper coding for the way you had it.  To have the button share the same event handler function you need a different approach that tests for which button is clicked.  INstead of that approach, below I am showing each button having its own handler function...

                 

                 

                stop();
                BTN1.addEventListener(MouseEvent.CLICK,mouseClick1);
                function mouseClick1(event:MouseEvent):void
                {
                gotoAndStop(2);
                }


                BTN2.addEventListener(MouseEvent.CLICK,mouseClick2);

                function mouseClick2(event:MouseEvent):void
                {
                gotoAndStop(3);
                }


                BTN3.addEventListener(MouseEvent.CLICK,mouseClick3);

                function mouseClick3(event:MouseEvent):void
                {
                gotoAndStop(4);
                }

                 

                 

                 

                 

                 

                 

                • 5. Re: Need some help with simple flash buttons
                  Aiguchi Level 1

                  Thanks a lot got it working perfectly now

                  • 6. Re: Need some help with simple flash buttons
                    Ned Murphy Adobe Community Professional & MVP

                    You're welcome

                    1 person found this helpful