?
Solved

Making CS4 Flash button link to URL

Posted on 2011-03-22
14
Medium Priority
?
413 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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

649 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