Adding a link to your Flash

Posted on 13. Jan, 2010 by Website Design Professional in Flash

Ok, I’m not an expert in Flash (YET!) but I was surprised at how difficult it was to track down exactly how to do this.

So, you have a Flash file and you want to be able to click on a portion of it and have that click open a URL of your choice. Some of the problems I ran into is that the getURL command is no longer functional in Actionscript 3.0, which is the current/latest version.  The code involved with the getURL command is much shorter but don’t be discouraged; it’s still a very easy thing to accomplish using the code I’ve listed below.

NOTE: there are a couple items you need to make certain of before you use this code:

  1. The instance name of the button/movie clip MUST be named to match your code below. If you don’t have the exact same name in both the Actionscript and as the instance name of your clip/button, it won’t work. Period. In this example, it’s named
    my_btn
  2. It’s best to put this code into a NEW LAYER in your Flash file. I call this layer ‘actions’ and it’s ALWAYS best to keep it separate to avoid any code issues.

Ok, here’s your code:

my_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

function mouseDownHandler(event:MouseEvent):void {

    navigateToURL(new URLRequest("http://www.wickedrelevant.com/"));
}

If you need additional help with this, or you’re a beginner with other questions, feel free to send me an email.

Share and Enjoy:
  • Facebook
  • Twitter
  • LinkedIn
  • RSS
  • Technorati
  • Digg
  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • MySpace
  • Sphinn
  • Print this article!
  • E-mail this story to a friend!

Leave a Reply