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"); }
12 Responses to Opening URLs in new browser windows using ActionScript 3.0 and ActionScript 2.0
Leave a Reply Cancel reply
Recent Posts
- Getting started with the TLFTextField class in ActionScript 3.0 and Flash CS5
- Adding tick marks to a Slider control in Flash using ActionScript 3.0
- Creating a vertical Slider control in Flash using ActionScript 3.0
- Creating a custom context menu item in Flash using ActionScript 3.0
- Rotating a Sprite object around its x-axis in Flash using ActionScript 3.0 and Flash Player 10
- Detecting when the user changes the color in a ColorPicker control in Flash using ActionScript 3.0
- Getting the currently selected color as a hexadecimal value on a ColorPicker control in Flash using ActionScript 3.0
- Toggling the text field on the ColorPicker control in Flash using ActionScript 3.0
- Creating a vertical Slider control in Flash using ActionScript 3.0
- Setting the number of columns on a ColorPicker control in Flash using ActionScript 3.0
Categories
- Bitmap (1)
- Components (72)
- Button (19)
- CheckBox (2)
- ColorPicker (6)
- ComboBox (1)
- DataGrid (8)
- FLVPlayback (7)
- Label (9)
- ProgressBar (2)
- Slider (3)
- TextArea (1)
- TextInput (7)
- UILoader (7)
- ContextMenu (1)
- Embed (4)
- ExternalInterface (2)
- Flex (7)
- Font (2)
- General (5)
- Graphics (2)
- JSFL (14)
- Loader (3)
- LoadVars (3)
- Microphone (1)
- migration (12)
- MovieClip (1)
- MovieClipLoader (1)
- Sound (2)
- TextField (1)
- TLFTextField (1)
- TransitionManager (1)
- Tween (1)
- Uncategorized (1)
- URLLoader (4)
- URLVariables (1)
- Video (1)
- XML (2)
Advertising
" RT @OReillyMedia: #Ebook Deal/Day: Learning JavaScript Design Patterns -
$11.99
(Save 50%)
http://t.co/ilcmSDv6 " — pdehaan


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
Hi Peter, I would like to know is there anyway to configure the new window attributes, like size, toolbars etc from within AS3
how can i give the url in xml
Holy weak tutorial. You can get this with code snippets in CS5.
Even more pathetic questions.
How about this:
How do you open up a sized window with actionScript 3?