Archive for January 24th, 2008

The nightmare that is “_blank” & Flex

UPDATE: I believe the example will work in all common browsers (Firefox, Safari, IE, Opera) on both PC & Mac platforms.

NOTE – If you’re using SWFObject 2.0, you need to upgrade to RC2!


I created a bug tracker listing for this issue a while back at It was closed – I believe improperly so.

Please consider visiting the listing for this issue. While you cannot vote because it’s been closed. You can comment, and you can add the listing to those items you are watching.

UPDATE: I revised the code to handle for Safari 2 (sort of). Essentialy, I was not getting a response from Safari 2 on the browserAgent request. My conditional was failing unexpectedly.I’ve revised the code, and confirmed that it now reaches the “Undefined” option. Which uses the standard navigateToURL(). And should work in Safari 2.Too those readers who still have access to Safari 2, if you could confirm that it is now working for you – much appreciated.- The Saj

PS – Special thanks to multi-Safari and to Subtlegradient for the fix that re-enables multi-safari. Which allowed me to install Safari 2 on my Mac for testing purposes. (Why Apple & Microsoft fail to see the need for us developers to run multiple browsers we will never know.)

One of the very first headaches I encountered with Flex was when I tried to pop-out a link using “_blank”. ActionScript 2.0 used _getURL(), in ActionScript 3.0 this was changed to navigateToURL().Imagine my horror when after uploading my new Flex app live to discover that clicking was caught by Firefox’s pop-up. The old _getURL() worked fine, but I really didn’t want to go back and re-write my app in Flash / AS 2.0A little research revealed a work-a-round using the externalInterface command to call out to the browser and pop open the window using the command.However, I would more recently discover all of my Flex applications failing to work in the new Safari 3.0, Safari 2.0 works with the externalInterface work-a-round but for whatever reason Safari 3.0 does not. Further research led to another work-a-round to check the browser brand then use conditional if/else logic to enable the application to either use the externalInterface() method if Firefox or the navigateToURL() method if another browser.Now for my applications I have made these into two separate re-usable classes. However, so as not to confuse those new to Flex and still unfamiliar with classes, I have made a simple and stupid example that incorporates all of the code in one MXML file. Hopefully this example will help you if you’ve encountered this issue:
(right-click to view source)

– The Saj

January 2008

Awesome Developer Conferences

Nxtbook MediaFormer Employer - Great Company

The Saj... "Dark Lord of the SWF"