1 Reply Latest reply: Oct 11, 2013 8:02 PM by GeorgeMcKinney RSS

    [Flex Mobile] take photo without lauching Camera application.

    havefreetime Community Member

      Hi there.

       

      Is it possible to take photo without lauching Camera app?

       

      Following source code must select PhotoApp when I click the button.  I wanna take a photo only using my app.

       

      I've searched enough in Google. Please give me a hint.

       

      Thanks in advanced.

       

      Kevin.

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

                 xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView"

                 creationComplete="view1_creationCompleteHandler(event)">

           <fx:Script>

                 <![CDATA[

                      import mx.events.FlexEvent;

                     

                      private var camera:CameraUI;

                      private var file:File;

                     

                     

                      protected function view1_creationCompleteHandler(event:FlexEvent):void

              {

                           // TODO Auto-generated method stub

                           if(CameraUI.isSupported)

                {

                                 camera = new CameraUI();

                                 camera.addEventListener(MediaEvent.COMPLETE, onComplete);

                                 camera.addEventListener(ErrorEvent.ERROR, onError);

                }

              }

                     

                      private function onError(event:ErrorEvent):void

              {

                           trace("Error");

              }

                     

                      private function onComplete(event:MediaEvent):void

              {

                           var mediaPromise:MediaPromise = event.data;        

              }

                     

                      private function captureImg(event:MouseEvent):void

              {

                camera.launch(MediaType.IMAGE);

              }

                     

                     

                     

                 ]]>

           </fx:Script>

          

           <s:Panel title="TakePhoto" width="90%" height="90%" top="5">

                 <s:Button label="TakePhoto" click="captureImg()" />

           </s:Panel>

      </s:View>