Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Mobile - Manually set screen orientation and change UI

Engaged ,
May 08, 2014 May 08, 2014

I'm trying to use the devices camera, when I do, it always shows in landscape mode. So i want to change the screen rotation manually and then reposition the ui. I'm trying to us an event but it doesn't work.

Does anyone have any suggestions?

Here is my code:

package 

{

  import flash.display.Sprite;

  import flash.media.Camera;

  import flash.media.Video;

  import flash.display.StageAspectRatio;

  import flash.display.StageScaleMode;

  import flash.display.StageAlign;

  import flash.events.StageOrientationEvent;

  public class Main extends Sprite

  {

  public function Main()

  {

  stage.scaleMode = StageScaleMode.NO_SCALE;

  stage.align = StageAlign.TOP_LEFT;

  this.stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChanged);

  this.stage.setAspectRatio( StageAspectRatio.LANDSCAPE );

  }

  private function orientationChanged(event:StageOrientationEvent):void

  {

  var cam:Camera = Camera.getCamera();

  cam.setMode(800, 400, 30);

  var vid:Video = new Video();

  vid.width = cam.width;

            vid.height = cam.height;

  vid.attachCamera(cam);

  addChild(vid);

  }

  }

}

TOPICS
ActionScript
176
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation