8
Mar
2006

FAB – Flex / AJAX bridge

FAB – Flex/AJAX Bridge – is a library created by Ely Greenfield, who is a good friend and Flex Architect.

FAB lets you control Flex applications using JavaScript. Method calls just work, and getters and setters are converted to method calls (because browsers don’t support getters and setters yet).

You can even attach event listeners from JavaScript and pass function objects back and forth. For example, you can create an MXML file with a button in it and drive all of the logic from within your HTML/JavaScript.

MXML:

<mx:Application xmlns:mx=”http://www.macromedia.com/2005/mxml”>
    <fab:FABridge xmlns:fab=”bridge.*” />
    <mx:Button id=”okButton” label=”OK” />
</mx:Application>

JavaScript:

function init()
{
    var flexApp = FABridge.flash.root();
    flexApp.okButton().addEventListener(“click”, handleClick);
}

function handleClick(event)
{
    // handle the click event here.
}

You can read more about it on Ely’s blog, which I predict will be worth reading.

http://www.quietlyscheming.com/blog/2006/03/06/flex-and-ajax/

3 Responses to “FAB – Flex / AJAX bridge”

  1. Robert Penner

    Slight correction: it’s called “Flex Ajax Bridge”. Bridging ActionScript and Flex isn’t as noteworthy. =)

  2. Sho

    Doh!

    Good catch. Thanks, Robert.

  3. John Dowdell

    Is there any introspection, so that your JavaScript can know or confirm what the applet exposes? Or would the workflow be to document the available calls in both scripting environments, or to keep both open, so that you know proper names like “okButton” and such?

Leave a Reply