Skip to main content
DJ Gecko
Inspiring
March 28, 2014
Question

Using devices camera input in portrait

  • March 28, 2014
  • 1 reply
  • 351 views

Hi,

I'm using the devices camera and I want to use it in my app and have the app in portrait. The problems is that when I get the camera while the app is in portrait the camera is always rotated wrong. The camera's rotation is fine when using landscape.

Does anyone have any solutions?

Here is my code:

package 

{

 

          import flash.display.MovieClip;

          import flash.media.Camera;

          import flash.media.Video;

          import flash.display.StageScaleMode;

          import flash.display.StageAlign;

 

 

          public class Main extends MovieClip

          {

                    private var cam:Camera;

                    private var vid:Video;

 

                    public function Main()

                    {

                              stage.scaleMode = StageScaleMode.NO_SCALE;

                              stage.align = StageAlign.TOP_LEFT;

 

                              cam = Camera.getCamera();

                              trace(Camera.names);

                              cam.setMode(stage.fullScreenWidth, stage.fullScreenHeight, 30);

                              trace("cam.width = " + cam.width);

                              trace("cam.height = " + cam.height);

                              vid = new Video(cam.width, cam.height);

                              vid.attachCamera(cam);

                              addChildAt(vid, 0);

                    }

          }

 

}

This topic has been closed for replies.

1 reply

Participating Frequently
March 28, 2014

Depending on your situation, it is possible to put the Video inside a MovieClip (not sure if you can do it with DisplayObject) and just rotate the MovieClip however you want. If portrait is wrong while landscape is ok, then you'll probably need to listen for orientation events and handle accordingly. Good luck