Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 510

Programming actionscript 3.0
Table of Contents

Advertisement

Back in the IMManager constructor, one of two things happens depending on the readiness of
the container. If
isContainerReady()
method, which completes the process of setting up communication with
setupCallbacks()
JavaScript. On the other hand, if
essentially put on hold. A Timer object is created and is told to call the
method every 100 milliseconds, as follows:
private function timerHandler(event:TimerEvent):void
{
// Check if the container is now ready.
var isReady:Boolean = isContainerReady();
if (isReady)
{
// If the container has become ready, we don't need to check anymore,
// so stop the timer.
Timer(event.target).stop();
// Set up the ActionScript methods that will be available to be
// called by the container.
setupCallbacks();
}
}
Each time the
timerHandler()
isContainerReady()
The code then stops the Timer and calls the
of setting up communication with the browser.
Exposing ActionScript methods to JavaScript
As the previous example showed, once the code determines that the browser is ready, the
method is called. This method prepares ActionScript to receive calls from
setupCallbacks()
JavaScript, as shown here:
private function setupCallbacks():void
{
// Register the SWF client functions with the container
ExternalInterface.addCallback("newMessage", newMessage);
ExternalInterface.addCallback("getStatus", getStatus);
// Notify the container that the SWF is ready to be called.
ExternalInterface.call("setSWFIsReady");
}
510
Using the External API
returns
isContainerReady()
method gets called, it once again checks the result of the
method. Once the container is initialized, that method returns
, the code simply calls the
true
returns
false
method to finish the process
setupCallbacks()
, the process is
timerHandler()
true.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents