2 Replies Latest reply on Nov 18, 2018 6:39 PM by Fanous

    Why this AS3 function change the image on mobile?

    Fanous

      this is my as3 function to load images from gallery to my adobe air android app . it loads picture to container , but every time , it reduce the image quality and save it on mobile ! I load one picture for 12 times and take a screenshot from that , so you can see the result in the picture. Do you have any idea what is the problem and how to fix this ?

      pic.jpg

      function load_the_bg(e: MouseEvent)
      {
        
      var mediaSource:CameraRoll = new CameraRoll();
        
      var imageLoader:Loader;

        
      if( CameraRoll.supportsBrowseForImage )
        
      {
        mediaSource
      .addEventListener( MediaEvent.SELECT, imageSelected );
        mediaSource
      .addEventListener( Event.CANCEL, browseCanceled );
        mediaSource
      .browseForImage();
        
      }
        
      else
        
      {
        
      //show error
        
      }

        
      function imageSelected( event:MediaEvent )
        
      {
        mediaSource
      .removeEventListener( MediaEvent.SELECT, imageSelected );
        mediaSource
      .removeEventListener( Event.CANCEL, browseCanceled );

        
      var imagePromise:MediaPromise = event.data;
        imageLoader
      = new Loader();

        
      if( imagePromise.isAsync )
        
      {
        
      //log( "Asynchronous media promise." );
        imageLoader
      .contentLoaderInfo.addEventListener( Event.COMPLETE, imageLoaded );
        imageLoader
      .contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR, imageLoadFailed );
        imageLoader
      .loadFilePromise( imagePromise );
        
      }
        
      else
        
      {
        
      //log( "Synchronous media promise." );
        imageLoader
      .loadFilePromise( imagePromise );

        
      var pdo : DisplayObject = ax_container.getChildByName("alpha_bg");
        
      if (pdo)
        
      {
        ax_container
      .removeChild(pdo);
        
      }

        
      var ax_mv : Sprite = new Sprite();
        ax_mv
      .name = "alpha_bg";
        ax_mv
      .addChild(imageLoader);
        ax_container
      .addChild( ax_mv );
        
      //ax_container.alpha=.3;
        
      }
        
      }

        
      function browseCanceled( event:Event )
        
      {
        mediaSource
      .removeEventListener( MediaEvent.SELECT, imageSelected );
        mediaSource
      .removeEventListener( Event.CANCEL, browseCanceled );
        
      }

        
      function imageLoaded( event:Event )
        
      {
        imageLoader
      .contentLoaderInfo.removeEventListener( Event.COMPLETE, imageLoaded );
        imageLoader
      .contentLoaderInfo.removeEventListener( IOErrorEvent.IO_ERROR, imageLoadFailed );

        
      var pdo : DisplayObject = ax_container.getChildByName("alpha_bg");
        
      if (pdo)
        
      {
        ax_container
      .removeChild(pdo);
        
      }

        
      var ax_mv : Sprite = new Sprite();
        ax_mv
      .name = "alpha_bg";
        ax_mv
      .addChild(imageLoader);
        ax_container
      .addChild( ax_mv );
        
      //ax_container.alpha=.3;
        
      }

        
      function imageLoadFailed( event:Event )
        
      {
        imageLoader
      .contentLoaderInfo.removeEventListener( Event.COMPLETE, imageLoaded );
        imageLoader
      .contentLoaderInfo.removeEventListener( IOErrorEvent.IO_ERROR, imageLoadFailed );
        
      }
      }