Oct
10
2008

getURL in ActionScript 3

There is a little more to write when you want to link from Flash to some website using ActionScript 3. ActionScript 2 offered the getURL method, ActionScript 3 doesn't have it anymore.

It's a good practise to use try - catch statement to track any issues when navigating to the websites.
1
2
3
4
5
6
7
8
9
10
var myURL:String = "http://sierakowski.eu";
var myURLRequest:URLRequest = new URLRequest(myURL);
try
{
navigateToURL(myURLRequest, '_blank'); // target can be _blank, _parent
}
catch (error:Error)
{
trace("Error when navigating to website: "+error);
}

 

You can also use mailto: This e-mail address is being protected from spambots. You need JavaScript enabled to view it in your URL variable to create a link to send an email.

 

Comments 

 
0 #2 rnvr 2010-12-27 05:52
hello, i'm new to as, is it possible to change the URL to load swf files? not the link to websites

thnks
Quote
 
 
+2 #1 Gavin 2010-05-22 16:59
Or the quick one-liner:
navigateToURL(n ew URLRequest("website.com", "_blank"));
Quote
 

AS3 Tips

Follow me on Twitter