Some Android devices have additional physical inputs that we can take advantage of. For instance, the Motorola Droid has a slider keyboard, which includes a directional D-pad and the HTC Nexus One has a built-in trackball control.
We can respond to trackball and D-pad events through standard ActionScript event listeners.
1. First, import the following classes into your project:
import flash.display.Shape; import flash.display.Sprite; import flash.display.Stage; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.KeyboardEvent; import flash.text.TextField; import flash.text.TextFormat; import flash.ui.Keyboard;
2. Declare a
Shape
alongside aTextField
andTextFormat
object. These will be used for interaction and visual feedback.private var traceField:TextField; private var traceFormat:TextFormat; private var box:Shape;
3. We will then set up our
TextField
, apply aTextFormat
, and add it to theDisplayList...