Opening URLs in new browser windows using ActionScript 3.0 and ActionScript 2.0
The following example shows how you can open new browser windows from Flash Player using the navigateToURL() method in ActionScript 3.0 or the getURL() method in ActionScript 2.0.
Full code after the jump.
In ActionScript 3.0 you can use the navigateToURL() method to open a new browser window, as seen in the following example:
// ActionScript 3.0 /* Requires * - Button symbol on Stage with instance name "buttonSymbol" */ buttonSymbol.addEventListener(MouseEvent.CLICK, buttonSymbol_click); function buttonSymbol_click(evt:MouseEvent):void { var req:URLRequest = new URLRequest("http://www.adobe.com/"); navigateToURL(req, "_blank"); }
In ActionScript 2.0, you use the getURL() method to open a new browser window, as seen in the following example:
// ActionScript 2.0 (code on timeline) /* Requires * - Button symbol on timeline * - Button symbol on Stage with instance name "buttonSymbol" */ buttonSymbol.onRelease = function ():Void { getURL("http://www.adobe.com/", "_blank"); }
Or, in ActionScript 2.0 if you were placing code directly on instances on the Stage, as seen in the following example:
// ActionScript 2.0 (code directly on instance) /* Requires * - Button symbol on Stage */ on (release) { getURL("http://www.adobe.com/", "_blank"); }

Hi peter, there is something special I have to do to open the url in a new tab?
Daniel,
I typically specify the
targetattribute as “_blank”. I believe it may be up to the user’s browser settings to control whether that opens in a new tab or new browser window.Peter
For example, I searched around and found this link: “Internet Explorer 7: Open New Windows in Tabs in IE7″.
Hi Peter i want to open URL on enter frame … how is this done???
So how do you in Actionscript 3.0 get a Flash document to open a like in the “_parent” window since I use frames? If anyone knows the answer, please send answer via e-mail. Much appreciated.
is it possible to interact with the opened window?
if you want a one line command do this:
btn.addEventListener(MouseEvent.CLICK, function() {navigateToURL(new URLRequest(“http://www.adobe.com”, “_blank”))};
Hi Peter, I would like to know is there anyway to configure the new window attributes, like size, toolbars etc from within AS3
@Alex,
I believe if you want to control toolbars and window size, you’d need to launch the window via JavaScript using the ExternalInterface class.
Peter