Tag Archives: swfaddress

Flex Javascript communication

Communication between JavaScript and Flex applications can be done in many ways. Using SWFAddress and communicate with the help of the uri or using ExternalInterface flash communication interface are the most used.

The disadvantages of using SWFAddress is that the communication is slow and it had to change the uri, which is not always something the developer needs. In general the the Flex application listens for uri changes, simply by setting a timeout for a listener with very short period of time, like 10 milliseconds, and if some change occurs get’s the uri, parses it and process the changes.

From the beginning the hard-coded listening of the uri change is not a good idea. Even for very short timeouts it become risky when the user can click and skip an important refresh inside the flex application.

I strongly recommend the use of the build in ExternalInterface. The communication via ExternalInterface can be done in both directions to JavaScript to Flex and vice versa, which is the main advantage is the lack of programmatically added listening processes. Here all it’s done by the interface and the response from the other side is guaranteed.

There are tricky parts, of course, but in general it’s a secure and reliable way to talk between these two technologies.

A sample of the process you can find here.