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

loadFilePromise() method unavailable in the Loader class using FB 4.7 (target iOS)

Participant ,
Jun 17, 2014 Jun 17, 2014

Copy link to clipboard

Copied

Here's my code:

errorLoadFilePromise.jpg

Note that mpLoader is declared as a Loader class, yet when I try to use the loadFilePromise() method, it won't accept it syntactically.

Is there a reason for this?  I've checked and triple checked in the online docs ... It just shows me examples where  loadFilePromise() obviously works ...

What's wrong with this code? Why won't it work?

TOPICS
Development

Views

276

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

Participant , Jun 23, 2014 Jun 23, 2014

I took this code directly from an Action Script 3 example on the Adobe website, but it didn't work.

Here was my new solution after 6 days of trial and error (mostly error)


public class TakePhoto extends Sprite

  {

       private var cameraUI:CameraUI = new CameraUI();

       private var cameraRoll:CameraRoll = new CameraRoll();

       private var dataSource:IDataInput;

       private var eventSource:IEventDispatcher;

       private var testTxt:TextField = new TextField();

       public function

...

Votes

Translate

Translate
Participant ,
Jun 23, 2014 Jun 23, 2014

Copy link to clipboard

Copied

LATEST

I took this code directly from an Action Script 3 example on the Adobe website, but it didn't work.

Here was my new solution after 6 days of trial and error (mostly error)


public class TakePhoto extends Sprite

  {

       private var cameraUI:CameraUI = new CameraUI();

       private var cameraRoll:CameraRoll = new CameraRoll();

       private var dataSource:IDataInput;

       private var eventSource:IEventDispatcher;

       private var testTxt:TextField = new TextField();

       public function TakePhoto()

       {

            if( CameraUI.isSupported )

            {

                 testTxt.text = "CameraUI Initializing ...";

                 cameraUI.addEventListener( MediaEvent.COMPLETE, imageSelected );

                 cameraUI.addEventListener( Event.CANCEL, browseCanceled );

                 cameraUI.addEventListener( ErrorEvent.ERROR, mediaError );

                 cameraUI.launch( MediaType.IMAGE );

            }

            else

            {

                 testTxt.text = "CameraUI is not supported.";

            }

         }

         private function imageSelected(e:MediaEvent):void

            {

                 trace( "Media selected..." );

                 testTxt.text =  "Media selected...";

                 // Create a new imagePromise

                 var imagePromise:MediaPromise = e.data;

                 // Open our data source

                 dataSource = imagePromise.open();

                 if (imagePromise.isAsync )

                 {

                      trace("Asynchronous");

                      var eventSource:IEventDispatcher = dataSource as IEventDispatcher;

                      eventSource.addEventListener( Event.COMPLETE, onMediaLoaded );

                 }

                 else

                 {

                      trace("Synchronous");

                      readMediaData();

                 }

             }

            private function onMediaLoaded( event:Event 😞void

            {

                 trace("Media load complete");

                 readMediaData();

            }

             private function readMediaData():void

             {

                 testTxt.text = "Read Media Data";

                 trace("Read Media Data");

                 var imageBytes:ByteArray = new ByteArray();

                 dataSource.readBytes(imageBytes);

                 var loader:Loader = new Loader();

                 loader.loadBytes(imageBytes);

                 loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageAddToCamRoll);

                 loader.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, onMediaLoadError);

               }

            protected function imageAddToCamRoll(event:Event):void

            {

                 var loaderInfo:LoaderInfo = LoaderInfo(event.target);

                 var bmpData : BitmapData  = new BitmapData(loaderInfo.width, loaderInfo.height, false, 0xFFFFFF);

                 bmpData.draw(loaderInfo.loader);

                 try

                 {

                      cameraRoll.addBitmapData(bmpData);

                      trace( "image added to cameraRoll" );

                      testTxt.text = "Image added to cameraRoll";

                 }

                 catch (e:Error) {

                      trace( "Caught :: " + e );

                      testTxt.text = "Image failed to add to cameraRoll";

                 }

  }


This worked. Now I can take photos and store them in the Camera Roll.

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