8 Replies Latest reply on May 13, 2009 6:11 AM by Ned Murphy

    How to add actionscript to buttons

    srihari3d

      i m using adobe flash cs3 profficional software version...in my flash document i m using some buttons but i didn't get action script to that buttons...what is the reason?....can any one solve this problem....plz give me the reply....

        • 1. Re: How to add actionscript to buttons
          srihari3d Level 1

          hi guy whats up!!!!!!!!!!.....till now i didn't get any answer!!!!!!!!!!!!.............

          • 2. Re: How to add actionscript to buttons
            Ned Murphy Adobe Community Professional & MVP

            When you posted, it was likely bedtime for most of the folks that help here, so you need to be patient.  And the folks that help here do it voluntarily, so try not to complain if your posting doesn't get answered in a timely manner.  Very often a posting isn't answered because it doesn't provide any information that might help solve it--people don't realize that they need to help others to help them.  And yours would fall into that category.

             

            What code are you using that is not working and where are you placing it?

            • 3. Re: How to add actionscript to buttons
              srihari3d Level 1

              just simple button program...whenever click that button one image will be displayed...that is my logic....each button have one image...but the script is not working....how to add actions to buttons?...

              • 4. Re: How to add actionscript to buttons
                Ned Murphy Adobe Community Professional & MVP

                Show your script code.

                • 5. Re: How to add actionscript to buttons
                  srihari3d Level 1

                  stop();

                   

                  aboutus_btn.onRelease=function(){

                  gotoAndPlay(1);

                  gotoAndStop(3);

                  gotoAndStop(2);

                  gotoAndStop(6);

                  gotoAndStop(4);

                  gotoAndStop(5);

                  };

                  contactus_btn.onRelease=function(){

                  gotoAndPlay(2);

                  gotoAndStop(1);

                  gotoAndStop(3);

                  gotoAndStop(6);

                  gotoAndStop(4);

                  gotoAndStop(5);

                  };

                  employment_btn.onRelease=function(){

                  gotoAndPlay(3);

                  gotoAndStop(1);

                  gotoAndStop(2);

                  gotoAndStop(6);

                  gotoAndStop(4);

                  gotoAndStop(5);

                  };

                  movies_btn.onRelease=function(){

                  gotoAndPlay(4);

                  gotoAndStop(1);

                  gotoAndStop(2);

                  gotoAndStop(6);

                  gotoAndStop(3);

                  gotoAndStop(5);

                  };

                  technology_btn.onRelease=function(){

                  gotoAndPlay(5);

                  gotoAndStop(1);

                  gotoAndStop(2);

                  gotoAndStop(6);

                  gotoAndStop(4);

                  gotoAndStop(3);

                  //gotoAndStop(0);

                  };

                   

                  but it is not working properly..........can u plz give me short length code.....

                  logic is:each button display one image....

                  • 6. Re: How to add actionscript to buttons
                    Ned Murphy Adobe Community Professional & MVP

                    aboutus_btn.onRelease=function(){

                    gotoAndPlay(1);

                    gotoAndStop(3);

                    gotoAndStop(2);

                    gotoAndStop(6);

                    gotoAndStop(4);

                    gotoAndStop(5);

                    };

                     

                    Each of those gotoAndStop commands are telling the timeline that the code is in to go to different frames, so ultimately, you are likely ending up on the last in each list.  Code is executed almost instantaneously, before frame movements occur, so you won't see things moving from frame to frame if that is what you expect.  What do you really want?

                    • 7. Re: How to add actionscript to buttons
                      srihari3d Level 1

                      i want :-whenever click one button it will be displayed one image....i have 7 buttons & 7 images...(each button have different image)

                      • 8. Re: How to add actionscript to buttons
                        Ned Murphy Adobe Community Professional & MVP

                        I am going to have to make assumptions about your design since you haven't explained how you have it assembled.

                         

                        From what I've already mentioned, hopefully you understand that you can only use one gotoAndPlay for a button function for it to be sensible.

                         

                        aboutus_btn.onRelease=function(){

                             gotoAndPlay(1);

                        }

                         

                        And, assuming your images are one per frame and they are in frames 1 thru 7, and each button is supposed to go to a specific frame, then it will be better to use....

                         

                        aboutus_btn.onRelease=function(){

                             gotoAndStop(1);

                        }

                         

                        Either version of the code I showed are valid for making a button work, as long as the code is on the timeline in the presence of the buttons.  So if your buttons are not working, then you may not have given them the instance names your code uses.  Instance names are assigned by you in the properties panel, they are not the names you give them in the library.