13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Using the external API<br />

ActionScript<br />

class/value<br />

Array (elem<strong>en</strong>ts can be<br />

mixed types)<br />

A collection that allows<br />

mixed-type elem<strong>en</strong>ts,<br />

such as ArrayList or<br />

object[]<br />

Object A dictionary with string<br />

keys and object values,<br />

such as a HashTable with<br />

string keys<br />

Other built-in or custom<br />

classes<br />

C# class/value Format Comm<strong>en</strong>ts<br />

Note: By way of example, this table shows equival<strong>en</strong>t C# classes in addition to ActionScript classes; however, the external<br />

API can be used to communicate with any programming language or run time that supports ActiveX controls, and is not<br />

limited to C# applications.<br />

Wh<strong>en</strong> you are building your own applications using the external API with an ActiveX container application, you’ll<br />

probably find it conv<strong>en</strong>i<strong>en</strong>t to write a proxy that will perform the task of converting native function calls to the<br />

serialized XML format. For an example of a proxy class writt<strong>en</strong> in C#, see Inside the ExternalInterfaceProxy class.<br />

External API example: Communicating betwe<strong>en</strong><br />

ActionScript and JavaScript in a web browser<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

This sample application demonstrates appropriate techniques for communicating betwe<strong>en</strong> ActionScript and<br />

JavaScript in a web browser, in the context of an Instant Messaging application that allows a person to chat with him<br />

or herself (h<strong>en</strong>ce the name of the application: Introvert IM). Messages are s<strong>en</strong>t betwe<strong>en</strong> an HTML form in the web<br />

page and a SWF interface using the external API. The techniques demonstrated by this example include the following:<br />

Properly initiating communication by verifying that the browser is ready to communicate before setting up<br />

communication<br />

Checking whether the container supports the external API<br />

<br />

<br />

27.5<br />

<br />

<br />

Hello there!<br />

<br />

...<br />

<br />

<br />

<br />

John Doe<br />

<br />

<br />

33<br />

<br />

...<br />

<br />

or<br />

<br />

Calling JavaScript functions from ActionScript, passing parameters, and receiving values in response<br />

Making ActionScript methods available to be called by JavaScript, and performing those calls<br />

To get the application files for this sample, see www.adobe.com/go/learn_programmingAS3samples_flash. The<br />

Introvert IM application files can be found in the Samples/IntrovertIM_HTML folder. The application consists of the<br />

following files:<br />

Last updated 6/6/2012<br />

The property node<br />

defines individual<br />

elem<strong>en</strong>ts, and the id<br />

attribute is the<br />

numeric, zero-based<br />

index.<br />

The property node<br />

defines individual<br />

properties, and the<br />

id attribute is the<br />

property name (a<br />

string).<br />

ActionScript <strong>en</strong>codes<br />

other objects as null<br />

or as an empty object.<br />

In either case any<br />

property values are<br />

lost.<br />

848

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!