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

CameraUI on COMPLETE event not working on my phone

Explorer ,
May 07, 2014 May 07, 2014

Copy link to clipboard

Copied

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

        }

    }

}

TOPICS
Performance issues

Views

245

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

correct answers 1 Correct answer

Explorer , May 07, 2014 May 07, 2014

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

Votes

Translate

Translate
Explorer ,
May 07, 2014 May 07, 2014

Copy link to clipboard

Copied

LATEST

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

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