Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.display.Sprite;
- import flash.display.StageAlign;
- import flash.display.StageScaleMode;
- import flash.events.*;
- import qnx.ui.text.Label;
- import qnx.display.IowWindow;
- [SWF(backgroundColor="#dddddd")]
- public class AutoOrientTest extends Sprite {
- private var label:Label;
- public function AutoOrientTest() {
- stage.align = StageAlign.TOP_LEFT;
- stage.scaleMode = StageScaleMode.NO_SCALE;
- label = new Label();
- label.height = 100;
- label.width = 600;
- label.text = "Auto-orient test";
- addChild(label);
- makeline();
- stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, handleOrientationChanging);
- stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, handleOrientation);
- addEventListener(Event.ACTIVATE, onActivate);
- }
- private function onActivate(e:Event):void {
- trace(e.type, stage.orientation);
- label.text = e.type + ": " + stage.orientation;
- makeline();
- }
- private function handleOrientationChanging(e:StageOrientationEvent):void {
- trace(e);
- if (e.afterOrientation == 'rotatedRight')
- e.preventDefault();
- }
- private function handleOrientation(e:StageOrientationEvent):void {
- trace(e.type, e.beforeOrientation, e.afterOrientation, stage.orientation);
- label.text = e.type + ": " + stage.orientation;
- makeline();
- }
- private function makeline():void {
- graphics.clear();
- graphics.lineStyle(5, 0x88ff00);
- graphics.moveTo(5, 5);
- graphics.lineTo(stage.stageWidth - 5, stage.stageHeight - 5);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement