Monday, May 10, 2010

How to add hyperlink to flash button? - Flash CS4

1) Click on the button that you wish to put the hyperlink


Figure 1: Flash screen

2) Look under properties (Windows > Properties) and look at the instance name (highlighted in figure 1).

3) If the instance name is not entered (it will show like figure 1), please give it a name like “btnService “. If you are doing correctly, you will be able to see the result like figure 2.


Figure 2: The instance has a name now


4) Click anywhere on the flash screen. If you need guidelines on where to click, just click on the empty space (green box in figure 2)

5) Go to action (Windows > Actions). If there are no code in the action script, that is good. Just put “import flash.net.navigateToURL;” in the first line. If you are doing correctly, you will be looking at the figure 3. If there are already codes in the action, just find if you have the same command in it. If already exist, please don’t add the same line again.

Figure 3: MY first code
6) Let start putting the code below
--- start copy the code below ---


[btnname].addEventListener(MouseEvent.MOUSE_DOWN, [btnname]mouseDownHandler);

function [btnname]mouseDownHandler(event:MouseEvent):void {
navigateToURL( new URLRequest("aboutus.html"), "content" );
}


--- end copy ----
7) After you have copy the code into the actions, just replace all value “[btnname]” to your button name (which you have specific on step 3)
8) Change the value “aboutus.html” in the code to some url or file that you which to link to and that’s it. If you are doing correctly, you will be looking at figure 4


Figure 4: My final code

No comments:

Post a Comment