Skip to main content
Inspiring
May 7, 2014
Answered

CameraUI on COMPLETE event not working on my phone

  • May 7, 2014
  • 1 reply
  • 301 views

I have this weird issue encountered using adobe air. I was trying to study the cameraui and tested it on my phone.

The issue is when I start capturing the image, the image did not save into gallery. it also did not went to the line of  "trace( "Media captured..." );".

I'm just wondering because when I tested it on the other device, it works perfectly.

I hope you could help guys. Thank you so much.

This is the code that I used.

package com.movent

{

    import flash.desktop.NativeApplication;

    import flash.display.BitmapData;

    import flash.display.Loader;

    import flash.display.LoaderInfo;

    import flash.display.Sprite;

    import flash.display.StageAlign;

    import flash.display.StageScaleMode;

    import flash.events.ErrorEvent;

    import flash.events.Event;

    import flash.events.IOErrorEvent;

    import flash.events.MediaEvent;

    import flash.events.MouseEvent;

    import flash.filesystem.File;

    import flash.media.Camera;

    import flash.media.CameraRoll;

    import flash.media.CameraUI;

    import flash.media.MediaPromise;

    import flash.media.MediaType;

    import flash.media.Video;

    public class Main extends Sprite

    {

        private var deviceCameraApp:CameraUI = new CameraUI();

        private var imageLoader:Loader;

        public function Main()

        {

           

//            this.stage.align = StageAlign.TOP_LEFT;

//            this.stage.scaleMode = StageScaleMode.NO_SCALE;

           

            if( CameraUI.isSupported )

            {

                trace( "Initializing camera..." );

               

                deviceCameraApp.addEventListener( MediaEvent.COMPLETE, imageCaptured );

                deviceCameraApp.addEventListener( Event.CANCEL, captureCanceled );

                deviceCameraApp.addEventListener( ErrorEvent.ERROR, cameraError );

                deviceCameraApp.launch( MediaType.IMAGE );

            }

            else

            {

                trace( "Camera interface is not supported.");

            }

           

        }

       

        private function imageCaptured( event:MediaEvent ):void

        {

            trace( "Media captured..." );

           

            var imagePromise:MediaPromise = event.data;

           

            if( imagePromise.isAsync )

            {

                trace( "Asynchronous media promise." );

                imageLoader = new Loader();

                imageLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, asyncImageLoaded );

                imageLoader.addEventListener( IOErrorEvent.IO_ERROR, cameraError );

               

                imageLoader.loadFilePromise( imagePromise );

            }

            else

            {

                trace( "Synchronous media promise." );

                imageLoader.loadFilePromise( imagePromise );

                showMedia( imageLoader );

            }

        }

       

        private function captureCanceled( event:Event ):void

        {

            trace( "Media capture canceled." );

            NativeApplication.nativeApplication.exit();

        }

       

        private function asyncImageLoaded( event:Event ):void

        {

            trace( "Media loaded in memory." );

            showMedia( imageLoader );   

        }

       

        private function showMedia( loader:Loader ):void

        {

            this.addChild( loader );

        }

       

        private function cameraError( error:ErrorEvent ):void

        {

            trace( "Error:" + error.text );

            NativeApplication.nativeApplication.exit();

        }

    }

}

This topic has been closed for replies.
Correct answer angelo_lapus

I got it already. I just master reset my phone.

1 reply

angelo_lapusAuthorCorrect answer
Inspiring
May 8, 2014

I got it already. I just master reset my phone.