• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to capture a photo on iOS?

New Here ,
Jun 01, 2012 Jun 01, 2012

Copy link to clipboard

Copied

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!

TOPICS
ActionScript

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2012 Jun 01, 2012

Copy link to clipboard

Copied

:

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 );
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2012 Jun 01, 2012

Copy link to clipboard

Copied

first, thanks kglad for the response.

however i literally copy pasted it and published the new app, however it just takesa picture and goes back to the main app's screen without saving the photo in the camera roll.

This is the whole code including yours, is there any reason for this not be working or is it possibly missing something?

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

TFM.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler);

function  fl_TapHandler(event:TouchEvent):void

{

var cameraUI:CameraUI = new CameraUI();

cameraUI.addEventListener(MediaEvent.COMPLETE, onComplete);

cameraUI.launch(MediaType.IMAGE);

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 );

          }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2012 Jun 01, 2012

Copy link to clipboard

Copied

also just for clarifcation, i am using flash professional not flash builder or anything...and all this code is written in a seperate frame in the 'actions' layer.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 02, 2012 Jun 02, 2012

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines