Front-facing Camera Support in AIR 3

Adobe AIR for mobile has had consistent camera support since AIR 2.6, and now in AIR 3 (in beta, available on Adobe Labs), we’ve introduced support for front-facing cameras, as well. The introduction of the new position property on Camera along with the constants in the new CameraPosition class (BACK, FRONT, and UNKNOWN) allow you to chose which camera you want to get a reference to before attaching it to a Video object.

To be honest, the API is not quite as elegant as I’d like because making it consistent across platforms (mobile and desktop) meant having to compromise a little intuitiveness, but it’s easy enough to figure out, and most importantly, it’s entirely cross-platform. The code below shows a simple function that will return the requested camera:

// Get the requested camera. If it cannot be found,
// return the device's default camera instead.
private function getCamera(position:String):Camera
  for (var i:uint = 0; i < Camera.names.length; ++i)
    var cam:Camera = Camera.getCamera(String(i));
    if (cam.position == position) return cam;
  return Camera.getCamera();

For a full working example, check out the demo application called FrontCameraExample on Github (you can also download the FXP file). Keep in mind that AIR 3 is still in beta, so you might find bugs. If you do, here’s how to file them.

14 Responses to Front-facing Camera Support in AIR 3

  1. Pingback: Flash Codes: AIR 3 New Feature, Front Facing Camera Support | Adobe Flash Lite

  2. Pingback: Cool Stuff with the Flash Platform - 8/19/2011 | Remote Synthesis

  3. Chris River says:

    Ho Christian,
    I’ve been trying to get this to run in my Samsung Galaxy 10.1 tablet with absolutely no luck. I seem to get no results at all with the camera. (I can get the simulator to access the camera just fine). The application runs, I just get a white screen (with the view controls top and bottom) instead of the video. Do you know if there are issues with the Galaxy Tablet (10.1″)?


    • Christian Cantrell says:

      Thanks for pointing out that i did not un-comment the Android camera permission line in the app descriptor. I just checked in a new version.

    • Paul says:

      Hi Chris

      Have you had any luck hetting the Camera Position to work on your Samsung Galaxy Tab 10.1 ?

      I am tryinmg to figure it out and would appreciate any tips that you might have.



  4. Alex Yamane says:

    Dear Christian,

    I’ve got an app that I’m working on the streams the video from the cam (front or back), to a streaming recording server. Something strange, I wanted to ask you about. For the back cam, when you hold the device in portrait mode (right side up), the image is right side up. When I turn it sideways (landscape), image on screen is still right side up. However, on the front cam, holding the device in portrait mode, the video is upside down, while turning to the side (landscape), again works fine (right side up). Only the portrait mode position for from cam is returning the video on screen upside down. Any ideas or suggestions to fix this are greatly appreciated!

    with kind regards,

  5. Divij Kumar says:

    Hi Alex,

    The camera feed from both the front camera and back camera is un-mirrored. I tried with both front and back cameras and I was able to achieve this on Samsung nexus S under the following conditions.
    1. The camera app is set to auto orient in the app descriptor
    2. The device has a default portrait orientation
    3. The front camera is turned on and the device is put in the upside-down portrait orientation. However gingerbread OS does not support all four orientations. So in upside-down portrait, the app is actually in landscape orientation and due to the un-mirrored preview, the camera feed would appear inverted or upside-down.

    If you try the above on a Motorola Xoom with Gingerbread then this issue will not exist.

    Hope this helps,


    • Alex Yamane says:

      Dear Divij,

      Thank you for your feedback! I have a limited number of devices, and as I haven’t seen this issue on the web, I figured it may be device dependent. I’ll try the settings you suggested and see how it goes. Much appreciated!

      with kind regards,

  6. Pingback: Slides, Links, and Questions From my MAX 2011 Presentation « Christian Cantrell

  7. Pingback: AIR3.0新特性 | augustli's blog

  8. Paul says:


    Does anyone have an example of exactly how to implement the Camera position property on the Samsung Galaxy Tab 10.1 ? Chris did you get ir right ?

    I would appreciated any heads up on this one.

    Thanks Christain for posting this.


  9. Paul says:


    Looking for an implementation in Flash as opposed to Flash Builder but I will try to extract the code from the fxp file.


  10. Matt Nowicki says:

    Thanks for this code tip — works great for me! I have a question though. Is there a way to capture a still image from the camera in Flash Builder WITHOUT showing the video on screen? I’m writing an app that captures an electronic signature and I want to be able and snap a photo of the person signing while they sign.