As most Android devices have at least two screen orientations, that is, portrait and landscape, it is useful when developing for these devices to know what the current orientation is in order to properly display application user interface elements.
We will register an event listener on our Stage
to listen for StageOrientationEvent
changes:
1. First, import the following classes into your project:
import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageOrientation; import flash.display.StageScaleMode; import flash.events.StageOrientationEvent; import flash.text.TextField; import flash.text.TextFormat;
2. We will now declare a
TextField
andTextFormat
pair to relay text messages onto the device display:private var traceField:TextField; private var traceFormat:TextFormat;
3. Now, we will continue to set up our
TextField
, apply aTextFormat
, and add it to theDisplayList
. Here, we create a method to perform all of...