Page 1 of 1

How To Make A URL Link In AS3 getURL for Actionscript 3 Rate Topic: -----

#1 ayman_mastermind   User is offline

  • human.setType("geek");
  • member icon

Reputation: 127
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Posted 19 September 2009 - 12:49 AM

As we all know Action Script 3 differs a lot from Action Script 2 and has undergone major changes as it moves more towards the Object Oriented model of programming. Those changes have affected many of us especially beginners,sometimes many stuff in AS3 becomes confusing to those who are used to AS2. One of the biggest changes in AS3 is the way in which a URLs can be called.

In This tutorial I will show you the alternative for the good old getURL() function that was included in AS2 and has undergone major changes in AS3 to an extent that it is no more functional in AS3.

In the old days(AS2), we used to do it like this:

getURL("link", "target");

In AS3 it is much more different here is how it is done:

var myUrl:String = "http://theSiteYouWantToLoad";
var myRequest:URLRequest = new URLRequest(myUrl);

try {
  navigateToURL(myRequest, 'target'); // second argument is target
} catch (e:Error) {
  trace("An Error Occurred while trying to open the link!");

Here is an explanation for the process, first of all you will have to initialize a variable with type string in which you store the link to the site. Next you will have to create an instance of a URLRequest and submit your URL into it as an argument. Next you will be able to open the Url through the method: navigateToURL() instead of getURL(). In this case you will have to supply your URL request(myRequest) as an argument along with the target of your link e.g. _blank

You have to make sure to include your navigateToURL() statement in try...catch block in order to catch any exception that may result during execution as shown in the code above.

Beginners may find the AS3 way complex but actually it is much better in terms of flexibility, security and error handling. I hope this simple tutorial has helped, good luck in you AS3 scripting and have a good day :)

Is This A Good Question/Topic? 1
  • +

Replies To: How To Make A URL Link In AS3

#2 charlesdavis   User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 14
  • Joined: 23-April 15

Posted 27 April 2015 - 12:05 AM

You can use navigateToURL() method as shown below.

navigateToURL(websiteURL, window);
Sample AS3 code for navigateToURL() :

function gotoPage(event:MouseEvent):void

var targetURL:URLRequest = new URLRequest(“”);

myBtn.addEventListener(MouseEvent.CLICK, gotoPage);

ote: Please keep in mind during implementation it will only work for AS3..not its another lower versions..
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1