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!
:
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 );
}
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 ); } |
North America
Europe, Middle East and Africa
Asia Pacific