How to Add Functionality to Your Buttons in Flash - dummies

How to Add Functionality to Your Buttons in Flash

By David Karlins, Doug Sahlin

To make buttons in Flash truly functional, you need to specify the page to which the button links. To do that, you must venture into the wild and wooly world of ActionScript. Here, ActionScript 2.0 is used. To make the buttons truly functional, follow these steps:

1Select the first button in your menu and choose Window→Actions.

This opens the Actions panel. If this is your first introduction to ActionScript, you might be reminded of Pandora’s box. The Actions panel has so many actions that they’re divided into what the Flash designers refer to as books. When you click a book, you have access to all the actions within that book. And sometimes books open other books.

2Click inside the right pane of the Action panel and type on(release).

This code tells Flash to execute the action when the mouse button is released.

3Type a left curly bracket ({).

This tells Flash where a sequence of actions will begin. Flash automatically inserts an ending curly bracket on the next line.

4Click the Global Functions book, click the Browser/Network book, and then double-click the getURL action.

This action tells Flash to navigate to the URL that is typed inside the parentheses.

5In the URL text field, type the URL for the web page that opens when the button is clicked.

The page you want to open when the button is clicked should be in the same folder as your Flash navigation menu. Therefore, just type the name of the file. For example, if you’re creating a button that links to the home page, the link is index.htm.

6Type a comma, beginning and ending quotes, and then type one of the options between the quotes.

If the button links to a page within the site, choose _self. If you’re opening a page from another site, choose _blank. At this point, your Actions panel should look like the one shown.

7Repeat Steps 2–6 for the remaining buttons in your menu.

You have to select each button in turn, and then add the ActionScript.

To save some time, select the three lines of code for the first button you create, right-click, and choose Copy from the context menu. Select each button in turn, open the Actions panel, place your cursor in the right side of the Actions panel, right-click, and then choose Paste from the context menu. Change the URL in the second line of code to the proper link for the button.

8Choose File→Save.

The Save dialog box appears.

9Enter a name for the file, specify the location where you want to save the file, and then click Save.

Saving Flash documents in the same folder as the other assets for the website is typically a good idea. Flash files are saved with the .fla extension. You can modify the FLA file at any time by reopening it. All the files you import and objects you create are saved with the file.