User Guide
20 Introduction to ActionScript 3.0
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 or loaded content, enabling you to better handle security errors.
Working with text
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
TextField.getLineMetrics() 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.
Compatibility with previous versions
As always, Flash Player provides full backward compatibility with previously published
content. Any content that ran in previous versions of Flash Player runs in Flash Player 9. The
introduction of ActionScript 3.0 in Flash Player 9, however, does present some challenges for
interoperability between old and new content running in Flash Player 9. The compatibility
issues include the following:
■ A single SWF file cannot combine ActionScript 1.0 or 2.0 code with ActionScript 3.0
code.
■ ActionScript 3.0 code can load a SWF file written in ActionScript 1.0 or 2.0, but it
cannot access the SWF file’s variables and functions.
■ SWF files written in ActionScript 1.0 or 2.0 cannot load SWF files written in
ActionScript 3.0. This means that SWF files authored in Flash 8 or Flex Builder 1.5 or
earlier versions cannot load ActionScript 3.0 SWF files.