Flex ExternalInterface

On October 26, 2007, in Flex, by Anuj Gakhar

In one of my recent projects, I had the requirement to open a browser window from within Flex on click of a button. Thats when I came across this Externalinterface call. Here is how I did it.
private function openWindow():void
ExternalInterface.call("w_ = function () { window.win = window
.open(‘http://yahoo.com’,’TestPage’,’width=700,height=500′); }");
Dont forget to do this though :-
import flash.external.ExternalInterface;[/xml]
Might be useful to some of you trying to achieve the same in your project.

Tagged with:  

8 Responses to Flex ExternalInterface

  1. radek says:

    Thats actually nice trick. It will be much more useful for communicationg with JavaScript directly – you can do browser programming from inside Flex.
    You can for example parse location, place divs, add or remove DOM nodes.
    I think you just forgot to mention the most important part is this:

    …call(“w_ = function() {…

    as it triggers JS function execution. And you can’t place var before w_ at it will not work at all.

  2. admin says:

    yes I agree to that. A whole lot of things can be done in terms of communicating with javascript and browser. placing a var before w_ will make it not work because then it will be treated as a flex variable? is that what you wanted to say?

  3. radek says:

    No – I have no idea why it won’t work with var but it doesn’t 🙂

  4. admin says:

    nice 🙂

  5. Amy says:

    I assume that FABridge will be popular once it’s outta beta status? This is something you would use with it, rather than ExternalInterface?

  6. admin says:

    I havent got my hands dirty yet with the FABridge but from the looks of it, it looks like an interesting library. Thanks for letting me know, I am gonna try some of the examples out there.

  7. Amy says:

    Great! I’ll be awaiting your posts on it! I haven’t played with it much do to not developing in Flex yet, but from what I heard about it at MAX 2007… it sounded like it could be quite useful.

  8. Anuj Gakhar says:

    Sure Amy, I am gonna try it over the next couple days and will post it here once I do that.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2011 Anuj Gakhar