21 Communicating between Flex and JavaScript

Goal

You’d like to integrate Flex with an existing JavaScript-powered HTML application.

Solution

Use either Flex’s ExternalInterface or the Flex-Ajax Bridge to enable two-way communication between Flex and JavaScript.

Communication between Flex and JavaScript

What does it mean that we can communicate between Flex and JavaScript? Pretty much anything you’d like to tell Flex to do from JavaScript, and vice versa. The communication can either be in terms of calling methods with ExternalInterface or setting properties in Flex via the Flex-Ajax bridge.

Even though we haven’t mentioned it much so far, since it’s not something that requires extra work to accomplish, Flex works great ...

Get Flex on Rails: Building Rich Internet Applications with Adobe Flex 3 and Rails 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.