g
Printer Friendly Version

editor  
BellaOnline's Flash and Animation Editor
 

Add a Hyperlink to a Button in Adobe Flash CS3 Professional

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 = "http://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.




Flash and Animation Site @ BellaOnline
View This Article in Regular Layout

Content copyright © 2013 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.



| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor