?
Solved

Making CS4 Flash button link to URL

Posted on 2011-03-22
14
Medium Priority
?
412 Views
Last Modified: 2012-05-11
Hello,

Can someone please tell me the exact code so that a button in Flash CS4 will go to a URL when clicked.

Please give the code and explain and I may need to follow up, because I have tried a few things.

Thanks very much.
0
Comment
Question by:jknance
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
14 Comments
 
LVL 17

Accepted Solution

by:
deepanjandas earned 2000 total points
ID: 35195335
Select the button and give it an instance name from the properties panel (say the instance name is linkBtn).

Then open the actions frame by pressing F9.

Place this code:
//do necessary imports for MouseEvent, URLRequest and navigateToURL;
linkBtn.addEventListener( MouseEvent.CLICK, onClickHandler, false, 0, true );

function onClickHandler( event:MouseEvent ):void{
    var request:URLRequest = new URLRequest( "http://www.google.com" );
    navigateToURL( request, "_blank" );
}

Open in new window


Warm Regards
Deepanjan Das
0
 

Author Comment

by:jknance
ID: 35198437
Hi Deepanjan,

Thanks for your response.  I tried it and got an error code, which I am attaching.

I gave the button an instance name and put it in the code.  Are you able to see the problem?

Thanks. Flash Compiler Error Code
0
 
LVL 17

Assisted Solution

by:deepanjandas
deepanjandas earned 2000 total points
ID: 35198760
First Select the instance, press F9, cut the whole piece of code, close the action panel, deselect the object.

Select the frame, press F9 and then paste the code.

Add the following lines first:

import flash.events.MouseEvent;
import flash.net.URLRequest;

Warm Regards
Deepanjan Das
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:jknance
ID: 35199035
I followed your instructions and got another error code.  I am attaching another image to show the error code, my timeline set up and the code that I pasted into the action area.

Thanks again for helping. Timeline, error code and code
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35199359
I guess you are using AS3.0.

Kindly share your fla, as the code seems to be fine, so there might be some other reasons.

Warm Regards
Deepanjan Das
0
 

Author Comment

by:jknance
ID: 35200413
Is there a way to do that privately since it is a file for a client? Can I delete the file after you have looked at it and we would just post the solution at the end, so everyone could see that?

Thanks
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35203676
I am not sure if you can delete the file. Alternatively you can email me and I will post the so;ution here.
You will get my email address from my blog.

Warm Regards
Deepanjan Das
0
 

Author Comment

by:jknance
ID: 35203755
Great, thanks.  I emailed it to you at your gmail.

Thanks.
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35203775
I will check and will let you know shortly.

Warm Regards
Deepanjan Das
0
 
LVL 17

Assisted Solution

by:deepanjandas
deepanjandas earned 2000 total points
ID: 35204004
As I guessed it right, you have been using as2.

So do the following:
Go to File > Publish Settings >
Select player as Flash Player 9, script as Actionscript 3 and press OK.

Now compile.

Warm Regards
Deepanjan Das
0
 

Author Comment

by:jknance
ID: 35207182
GREAT.  That worked.  One more quick question, please, and then it will be solved.

I have two more buttons which I put on different layers and then applied the same code to each, changing only the button instance name in the code and the URL and got this error code.  Do you know what I should change to have more than one button?

Thanks. Duplicate error code
0
 
LVL 17

Assisted Solution

by:deepanjandas
deepanjandas earned 2000 total points
ID: 35207481
You have created the same function twice, change the function names to be unique.

Warm Regards
Deepanjan Das
0
 

Author Closing Comment

by:jknance
ID: 35208316
Great help all the way to the end.  GREAT JOB!!
0
 

Author Comment

by:jknance
ID: 35208349
Thank you so much Deepanjan.  I was able to get everything working.  

For everyone, the final code for each button needs to have a different "onClickHander" name  (such as onClickHandler1, onClickHandler2, etc) for each button.  It appears twice in the code.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question