Example: Using The External Api With A Web Page Container - Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual

Programming actionscript 3.0
Table of Contents

Advertisement

In either case, the return value of the ActionScript function is passed back to the container
code, either directly as a value when the caller is JavaScript code in a browser, or serialized as
an XML-formatted string when the caller is an ActiveX container.
Example: Using the External API with a
web page container
This example application demonstrates appropriate techniques for communicating between
ActionScript and JavaScript in a web browser, in the context of an Instant Messaging
application that allows a person to chat with him or herself (hence the name of the
application: Introvert IM). Messages are sent between an HTML form in the web page and a
SWF interface using the External API. The techniques demonstrated by this example include
the following:
Properly initiating communication by verifying that the browser is ready to communicate
before setting up communication
Checking whether the container supports the External API
Calling JavaScript functions from ActionScript, passing parameters, and receiving values
in response
Making ActionScript methods available to be called by JavaScript, and performing those
calls
The Introvert IM application files can be found in the Samples/IntrovertIM_HTML folder.
The application consists of the following files:
File
IntrovertIMApp.mxml
com/example/programmingas3/
introvertIM/IMManager.as
com/example/programmingas3/
introvertIM/IMMessageEvent.as
com/example/programmingas3/
introvertIM/IMStatus.as
html-template/index.template.html
Description
The main application file consisting of the MXML user
interface.
The class that establishes and manages communication
between ActionScript and the container.
Custom event type, dispatched by the IMManager class
when a message is received from the container.
Enumeration whose values represent the different
"availability" status values that can be selected in the
application.
The template that is used to create the container HTML
page for the application. This file contains all the
JavaScript functions that make up the container part of
the application.

Example: Using the External API with a web page container

507

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents