Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ActionScript 3 - Navigate to URL

New Here ,
Feb 22, 2010 Feb 22, 2010

Hi all,

I am sufficient at Flash but new to Actionscript and have followed a tutorial chapter entitled "Creating Interactive Navigation" from the Adobe Flash CS4 CLASSROOM IN A BOOK series.

My Flash CS4 file is attached.

I have six thumbnails across the top of the page. When I click on a top thumbnail, its image shows up larger in the main panel below. That's it, very nice and simple.

I would like to take it one step further though.

Check out the file - Click on the top left thumbnail and you will see that I have added two buttons alongside the image in the main panel itself.

I would like to make it so that when a button is clicked, a new browser opens and you are taken to a URL e.g. Google's home page.

I have tried to do this myself but I just can't get it to work.


Can anyone please finish off the Flash CS4 file - test the SWF to make sure it works - and then re-upload it so that I can see how it works when finished.

It should be dead simple for someone who know what they are doing.

The file is complete with buttons ready-made even with instance names. I just need the AS in there to make it work.

Hope there is someone who can help me.

Thanks a lot.

TOPICS
ActionScript , Product issue
8.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 22, 2010 Feb 22, 2010

I doubt that anyone is going to download, edit, test, return your file for you.  Most of us here try to help solve problems where people can demonstrate code that isn't working for them.  Here's some code that I cut and paste that will open a new browser window.  See what you can do to adapt it...

btn1.addEventListener(MouseEvent.CLICK, btn1Click);


function btn1Click(evt:MouseEvent):void {

   var url:String = "http://www.google.com";

   var req:URLRequest = new URLRequest(url);

   navigateToURL(req, "_blank");

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2010 Feb 22, 2010

Thanks for the reply Ned,

Yes I fully understand what I am asking is a little out of the norm.

The code you have supplied is similar to what I have already tried from watching a number of tutorials.

I think I'm just missing something and was hoping someone would be kind enough to help me out.

If there is anyone who can spare 2 - 3 mins to have a peak at the file I would much appreciate it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2010 Feb 22, 2010
LATEST

Hi Ned & all,

Just to let you know I have successfully worked it out.

I knew I was missing something simple - I just needed to put the code in the corresponding actionscript keyframe to where the button sits on the timeline. Below is my finished code which works like a charm.

Thanks again for taking the time to answer Ned. You guys are priceless in your help to us novices.

googleButton_btn.addEventListener(MouseEvent.CLICK, buttonClicked1);

function buttonClicked1(event:MouseEvent):void
{
var buttonClicked1:URLRequest = new URLRequest("http://www.google.co.uk");
navigateToURL(buttonClicked1, "_blank");
}

yahooButton_btn.addEventListener(MouseEvent.CLICK, buttonClicked2);

function buttonClicked2(event:MouseEvent):void
{
var buttonClicked2:URLRequest = new URLRequest("http://www.yahoo.co.uk");
navigateToURL(buttonClicked2, "_blank");
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines