AS2 → AS3: Open New Browser Window

With the advent of ActionScript 3, there are new ways to do old things. Something as simple as opening up a new browser window in AS2 is a slight bit more complicated in AS3, but when all is said and done, the language makes sense and is very clear.

Let's take a look at opening a new browser window in AS2:

Actionscript:
  1. getURL("http://www.yahoo.com", "_blank");

And here is the AS3 version:

Actionscript:
  1. navigateToURL(new URLRequest("http://www.yahoo.com"), "_blank");

The navigateToURL function has replaced getURL and instead of taking a string it now takes a URLRequest. The second parameter is just like the getURL function, the browser window or HTML frame in which to display the document called by the URLRequest.

If you found this post useful, please consider leaving a comment, subscribing to the feed, or making a small donation.

4 Comments

Nice but in external class don't forget you need

import flash.net.URLRequest;
import flash.net.navigateToURL;

@J: that is correct but this was just on the timeline and its not necessary.

this doesn't work...please put the full code and perhaps a links to an example fla.
good work!
Thanks
B

umm, yes, it does work...?

Leave a comment

(required)

(required)