3 Replies Latest reply on Feb 5, 2007 6:34 AM by Kaibi

    Basic button?

    Kaibi
      I am very new to flash, and I've been all around it trying to find a way to make a button that opens up a website. How can I do that? Thx
        • 1. Re: Basic button?
          Level 7
          Kaibi,

          > I am very new to flash, and I've been all around it trying to
          > find a way to make a button that opens up a website. How
          > can I do that? Thx

          Have you created the button symbol yet? That's the artwork that shows
          up in your Library panel as a button and can be dragged to the Stage (the
          working area) as often as necessary. Every copy you drag to the Stage is
          called an "instance," and can be programmed with its own instructions, so
          that each button can do its own thing.

          There are two ways to program a button; you pick which one makes more
          sense to you. In either case, you're going to "listen" for a certain
          event -- namely, for the release of the mouse (it's been pressed, now it's
          been released) -- and then "handle" that event.

          VERSION A:
          Select your button on the Stage and look in the Property inspector. You'll
          see a text field in the upper left corner to provide an "instance name."
          This is where you have the opportunity to give this particular button its
          own identity. Type in a name that makes sense to you; for example, you
          might choose webButton.

          Click in the keyframe that holds this button -- or, better, create a new
          layer just for scripts, and click in that keyframe -- and open the Actions
          panel (Window > Actions). Type the following:

          webButton.onRelease = function():Void {
          getURL(" http://www.domain.com/page.html");
          }

          Here, you're assigning a function to the Button.onRelease even of this
          particular Button instance. When the user clicks and *releases,* the
          following will occur: the getURL() function sends the user to the URL
          specified. Note that the URL is in quotes. See the getURL() entry of the
          ActionScript 2.0 Language Reference for more detail.

          Note that the onRelease event follows the instance name you chose for your
          button.

          VERSION B:
          Rather than typing into a keyframe, you may attach code directly to the
          button itself. This is a much older approach, the way things were done in
          Flash 5.

          Click the button on the Stage to select it. Open the Actions panel and
          type:

          on (release) {
          getURL(" http://www.domain.com/page.html");
          }


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Basic button?
            Kaibi Level 1
            I did Version A of what you suggested, and got this:

            **Error** Scene=Scene 1, layer=Credits, frame=1:Line 1: Statement must appear within on handler
            webButton.onRelease = function():Void {

            Total ActionScript Errors: 1 Reported Errors: 1
            • 3. Re: Basic button?
              Kaibi Level 1
              Oh, wait, ok--I figured it out.

              MUCH THANKS! :)