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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 29: Basics of user interaction<br />

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

Your application can create interactivity by using ActionScript 3.0 to respond to user activity. Note that this section<br />

assumes that you are already familiar with the ActionScript 3.0 ev<strong>en</strong>t model. For more information, see “Handling<br />

ev<strong>en</strong>ts” on page 125.<br />

Capturing user input<br />

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

User interaction, whether by keyboard, mouse, camera, or a combination of these devices, is the foundation of<br />

interactivity. In ActionScript 3.0, id<strong>en</strong>tifying and responding to user interaction primarily involves list<strong>en</strong>ing to ev<strong>en</strong>ts.<br />

The InteractiveObject class, a subclass of the DisplayObject class, provides the common structure of ev<strong>en</strong>ts and<br />

functionality necessary for handling user interaction. You do not directly create an instance of the InteractiveObject<br />

class. Instead, display objects such as SimpleButton, Sprite, TextField, and various Flash authoring tool and Flex<br />

compon<strong>en</strong>ts inherit their user interaction model from this class and therefore share a common structure. This means<br />

that the techniques you learn and the code you write to handle user interaction in an object derived from<br />

InteractiveObject are applicable to all the others.<br />

Important concepts and terms<br />

It’s important to familiarize yourself with the following key user interaction terms before proceeding:<br />

Character code A numeric code repres<strong>en</strong>ting a character in the curr<strong>en</strong>t character set (associated with a key being<br />

pressed on the keyboard). For example, “D” and “d” have differ<strong>en</strong>t character codes ev<strong>en</strong> though they’re created by the<br />

same key on a U.S. English keyboard.<br />

Context m<strong>en</strong>u The m<strong>en</strong>u that appears wh<strong>en</strong> a user right-clicks or uses a particular keyboard-mouse combination.<br />

Context m<strong>en</strong>u commands typically apply directly to what has be<strong>en</strong> clicked. For example, a context m<strong>en</strong>u for an image<br />

may contain a command to show the image in a separate window and a command to download it.<br />

Focus The indication that a selected elem<strong>en</strong>t is active and that it is the target of keyboard or mouse interaction.<br />

Key code A numeric code corresponding to a physical key on the keyboard.<br />

More Help topics<br />

InteractiveObject<br />

Keyboard<br />

Mouse<br />

ContextM<strong>en</strong>u<br />

Last updated 6/6/2012<br />

555

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

Saved successfully!

Ooh no, something went wrong!