Copy link to clipboard
Copied
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);
}
}
}
Have something to add?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now