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…
getURL("http:www.mysite.com", "_blank")
…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");
navigateToURL(link, "_blank");
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…
new getURL("http://www.mysite.com");
…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.
Enjoy

wynds says:
October 23rd, 2010 at 8:37 pm
Sweet , thanks for the post.
I too ( a newbie to AS2 and 3) was ticked about the extra stuff needed for this , along with the change of button actions , but after looking at your class I’m gonna bury my feet in the sand at the beach and read some ObjectOrientedProgramming stuff.
tanks a lot
The Hippy says:
October 24th, 2010 at 2:39 pm
Thanks for the comment and best of luck with the learning process!