5 Replies Latest reply on Apr 25, 2006 7:04 PM by Craig Grummitt

    Button Action Script

    GCrame5832
      I want to create a scrip for a button so that it will go to a certain frame and play and then go to and frame in a completely different zone of the timeline and play. I have to use the action code on the botton and not on a key frame because depending on where it is clicked it will go to different parts. For instance I want someone to click on "Services" on the homepage and take them to the "Services" Page but I want the home page to fade away slowly and then really go to the "Services" page. The code i am using now work which is
      "on (release) {gotoAndPlay("Services");

      }" I am thinking it needs to be something like "on (release) {gotoAndPlay(10-20);
      then gotoAndPlay("Services")

      }"
        • 1. Re: Button Action Script
          GCrame5832 Level 1
          Bump. Does this make any sense? Amy help or direction would be appreciated. Thank you!
          • 2. Re: Button Action Script
            shyaway Level 1
            if you want to play from 10-20, you need a stop(); at frame 20
            there's no such thing as gotoAndPlay(10-20)
            • 3. Re: Button Action Script
              Craig Grummitt Level 3
              i am assuming that regardless of the button clicked, the user would first see the home page fade away slowly, and then be directed to the correct page.

              Your best bet would be to set a variable - go to the fade and then on frame 20 have actionscript which goes to the correct page depending on what the variable is set to...
              i.e.
              // this goes on the button:
              on(release) {
              section="Services";
              gotoAndPlay(10);
              }
              //this goes on frame 20
              gotoAndPlay(section);
              • 4. Re: Button Action Script
                GCrame5832 Level 1
                quote:

                Originally posted by: Craig Grummitt
                i am assuming that regardless of the button clicked, the user would first see the home page fade away slowly, and then be directed to the correct page.

                Your best bet would be to set a variable - go to the fade and then on frame 20 have actionscript which goes to the correct page depending on what the variable is set to...
                i.e.
                // this goes on the button:
                on(release) {
                section="Services";
                gotoAndPlay(10);
                }
                //this goes on frame 20
                gotoAndPlay(section);


                This would work but depending on what button is pushed the second selection can be different, that is why all of the script has to be in the button. Any more ideas?
                • 5. Re: Button Action Script
                  Craig Grummitt Level 3
                  what do you mean by "the second selection can be different"? i maintain that you won't (what's more can't really) put all the script in the button.

                  if the other buttons go to other sections then replace the section name in the variable.

                  if the other buttons need to do other things other than just go to a section, then you could replace what i coded for frame 20 with the following:
                  //this goes on frame 20
                  if (section =="Services") {
                  gotoAndPlay("Services");
                  else if (section==".......") {
                  //do something else
                  } else etc....