Skip navigation
royhermann
Currently Being Moderated

how to capture a photo on iOS?

Jun 1, 2012 2:29 PM

Tags: #app #camera #iphone #3.0 #ios #actionscript #event #cameraui

I have built this simple code that calls the iphones camera interface once the user taps the button "TFM" :

 

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

 

 

 

TFM.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler); //when you tap on TFM

 

 

function fl_TapHandler(event:TouchEvent):void

{

 

      var cameraUI:CameraUI = new CameraUI();

     cameraUI.launch( MediaType.IMAGE );

}

 

From what i understand i add an event listener that is trigerred once the picture is complete, and in this event listener i create a function which saves the captured photo into the users camera roll :

 

 

cameraUI.addEventListener( MediaEvent.COMPLETE, onComplete);

 

What do i code for the "onComplete" function inorder to save the photo on the users phone (in camera roll) ?

 

 

 

 

Thanks!

 
Replies
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 1, 2012 9:46 PM   in reply to royhermann

    :

     

     

     

    Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

     

     

     

    TFM.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler); //when you tap on TFM

     

     

    function fl_TapHandler(event:TouchEvent):void

    {

     

          var cameraUI:CameraUI = new CameraUI();

         cameraUI.launch( MediaType.IMAGE );

    }

     

     

     

     

    cameraUI.addEventListener( MediaEvent.COMPLETE, onComplete);
     function onComplete( e:MediaEvent ):void { 
    var imagePromise:MediaPromise = e.data; 
    if( imagePromise.isAsync ) {
    var imageLoader:Loader = new Loader();
    imageLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, asyncImageLoaded );
    imageLoader.loadFilePromise( imagePromise );
    } else {
    imageLoader.loadFilePromise( imagePromise );
    showMedia( imageLoader );
    }

    function asyncImageLoaded( e:Event ):void {
    showMedia( e.target.loader );
    }
    function showMedia( loader:Loader ):void {
    this.addChild( loader );
    }
     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 2, 2012 6:13 AM   in reply to royhermann

    you use the cameraui class if you want to add a bitmap of the just snapped image to your flash app.

     

    if you want to save an bitmapdata object from flash to the cameraroll, you should be using the cameraroll class.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points