Actionscript 3 getURL() class
I don’t know about you, but one of the things that I miss most about AS2 is the simplicity to use…
…to launch a web address.
Nowadays you have to set up a URLRequest and then use the navigateToURL command, like this:
var link:URLRequest = new URLRequest("http://www.mysite.com");
It’s straightforward enough, but it’s long winded and a bit annoying when you’re used to such a short command. So, I’ve gone ahead and created myself a getURL class which you’re welcome to download and use if it bugs you too.
Once installed in your AS directory, all you have to type is…
…to launch a site. Don’t forget you’ll also need to import the class if your preferred coding application doesn’t immediately spot it.
Unlike the AS2 original, I’ve set it up so that the target is automatically “_blank”…this is simply because it’s my preference when launching URLs from a button (as they tend to be external websites). If you wish to change this, simply type something like…
new getURL("http://www.mysite.com", "_self");
…or replace “_self” with whatever your preferred target is.