« Slides from Flashforward 2006 | Main | Some personal thoughts on the Flex/AJAX Bridge... »

March 08, 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/

Posted by sho at March 8, 2006 09:07 AM

Trackback Pings

TrackBack URL for this entry:
http://weblogs.macromedia.com/mtadmin/mt-tb.cgi/7166

Comments

Slight correction: it's called "Flex Ajax Bridge". Bridging ActionScript and Flex isn't as noteworthy. =)

Posted by: Robert Penner at March 8, 2006 10:52 AM

Doh!

Good catch. Thanks, Robert.

Posted by: Sho at March 8, 2006 11:06 AM

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?

Posted by: John Dowdell at March 8, 2006 12:06 PM