Flash Player API features

The Flash Player API in ActionScript 3.0 contains many new classes that allow you to control objects at a low level. The architecture of the language is completely new and more intuitive. While there are too many new classes to cover in detail here, the following sections highlight some significant changes.

Subtopics

DOM3 event model
Display list API
Handling dynamic data and content
Low-level data access
Working with text

DOM3 event model

Document Object Model Level 3 event model (DOM3) provides a standard way of generating and handling event messages so that objects within applications can interact and communicate, maintaining their state and responding to change. Patterned after the World Wide Web Consortium DOM Level 3 Events Specification, this model provides a clearer and more efficient mechanism than the event systems available in previous versions of ActionScript.

Events and error events are located in the flash.events package. The Flash components framework uses the same event model as the Flash Player API, so the event system is unified across the Flash platform.

Display list API

The API for accessing the Flash Player display list--the tree that contains any visual elements in a Flash application--consists of classes for working with visual primitives in Flash.

The new Sprite class is a lightweight building block, similar to the MovieClip class but more appropriate as a base class for UI components. The new Shape class represents raw vector shapes. These classes can be instantiated naturally with the new operator and can be dynamically re-parented at any time.

Depth management is now automatic and built into Flash Player, rendering assignment of depth numbers unnecessary. New methods are provided for specifying and managing the z-order of objects.

Handling dynamic data and content

ActionScript 3.0 contains mechanisms for loading and handling assets and data in your Flash application that are intuitive and consistent across the API. The new Loader class provides a single mechanism for loading SWF files and image assets and provides a way to access detailed information about loaded content. The URLLoader class provides a separate mechanism for loading text and binary data in data-driven applications. The Socket class provides a means to read and write binary data to server sockets in any format.

Low-level data access

Various APIs provide low-level access to data that was never before available in ActionScript. For data that is being downloaded, the URLStream class, which is implemented by URLLoader, provides access to data as raw binary data while it is being downloaded. The ByteArray class lets you optimize reading, writing, and working with binary data. The new Sound API provides detailed control of sound through the SoundChannel and SoundMixer classes. New APIs dealing with security provide information about the security privileges of a SWF file or loaded content, enabling you to better handle security errors.

Working with text

[code correction: 6/15/2007] ActionScript 3.0 contains a flash.text package for all text-related APIs. The TextLineMetrics class provides detailed metrics for a line of text within a text field; it replaces the TextFormat.getTextExtent() method in ActionScript 2.0. The TextField class contains a number of interesting new low-level methods that can provide specific information about a line of text or a single character in a text field. These methods include getCharBoundaries(), which returns a rectangle representing the bounding box of a character, getCharIndexAtPoint(), which returns the index of the character at a specified point, and getFirstCharInParagraph(), which returns the index of the first character in a paragraph. Line-level methods include getLineLength(), which returns the number of characters in a specified line of text, and getLineText(), which returns the text of the specified line. A new Font class provides a means to manage embedded fonts in SWF files.


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00000010.html