Hyperlink to a Button in Flash CS3

Hyperlink to a Button in Flash CS3
I have received many requests from readers about creating links in Flash movies that will take your visitor to another website such as your eBay store. In most cases, this link will either be a button or a text link. In this tutorial, we will take a look at how to create a button link in your Flash movie.

I am assuming that you have already created a button symbol that we will name "ebayButton" for the purpose of this tutorial. If you are reading this tutorial without a Flash project in mind, that's OK. We will use a built-in button component for demonstration purposes. If you are working on a Flash project, you might want to use different names for the symbol and instance names.

  1. Start a new ActionScript 2 Flash project or open your current project into Flash. If you are starting with a blank project, you will have one Layer and one Keyframe in the Timeline. If you are using an ongoing project, go to the Keyframe on the Timeline where you wish the button action to occur.

  2. If you need a button, you will find it in the Components panel (Window, Components). Now, click and drag an instance of the Button component from the panel onto the Stage.

  3. We need to give the button a Label so that we will remember its purpose. At the bottom of the workspace, click on the Parameters tab. You will see a list of parameters. The default label for the label parameter is "Label". Let's change this to "Go" or whatever name you wish to use. When you click Enter, you will notice that the label on our button has changed to "Go".

  4. Now we need to give the button an instance name so that we can program the button with ActionScript. Click on the Properties tab to go to the Properties panel. Let's give this button the instance name of "ebayButton".

  5. Click on the stage to deselect the button and go back to the Keyframe on the Timeline. Click Window, Actions from the Menu bar to open the Actions panel. Type the following code into the panel.

ebayButton.addEventListener(MouseEvent.CLICK, goWhere)
function goWhere (evt) {
var url = "https://myworld.ebay.com/name_of_your_eBay_store"
navigateToURL(new URLRequest(url))

This code creates an Event Listener for your ebayButton (ebayButton.addEventListener) and when the button is clicked (MouseEvent.CLICK) Flash will preform the goWhere function which will send your visitor to your eBay store.

Copyright 2018 Adobe Systems Incorporated. All rights reserved. Adobe product screen shot(s) reprinted with permission from Adobe Systems Incorporated. Adobe, Photoshop, Photoshop Album, Photoshop Elements, Illustrator, InDesign, GoLive, Acrobat, Cue, Premiere Pro, Premiere Elements, Bridge, After Effects, InCopy, Dreamweaver, Flash, ActionScript, Fireworks, Contribute, Captivate, Flash Catalyst and Flash Paper is/are either [a] registered trademark[s] or a trademark[s] of Adobe Systems Incorporated in the United States and/or other countries.

Related Articles
Editor's Picks Articles
Top Ten Articles
Previous Features
Site Map

Content copyright © 2023 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.