Flex applications require the Flash Player runtime environment to work. For this reason, it is common to think of Flex applications as being confined to Flash Player. However, it is entirely possible for a Flex application to communicate with the host application. For example, if a Flex application is running within a web browser, the application can interact with the browser. If a Flex application is running within a desktop executable, it can interact with that executable. This allows you to create integrated applications that span beyond the Flash Player context.
Flex application/host application communication takes place via a Flash Player class called
ExternalInterface allows you to make synchronous calls to host application methods from the Flex application, and from the host application to Flex application methods.
ExternalInterface is quite simple to work with, and in most cases, it is quite appropriate.
flash.external.ExternalInterface class defines two static methods, named
call( ) and
addCallback( ), enabling Flex-to-host-application communication and host-application-to-Flex communication, respectively.
call( ) method allows you to call a method of the host application by passing it the name of the method. If the host application method expects parameters, you can pass those parameters to the
call( ) method following the name of the host application method. For ...