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

Why this AS3 function change the image on mobile?

Community Beginner ,
Nov 17, 2018 Nov 17, 2018

Copy link to clipboard

Copied

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

Views

256

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
Community Expert ,
Nov 18, 2018 Nov 18, 2018

Copy link to clipboard

Copied

Hi.

Maybe I'm missing something, but where is the code you're using to save the image back to the device?

Because it wouldn't be possible to alter an actual image file by only loading it to RAM, I guess.

Regards,

JC

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
Community Beginner ,
Nov 18, 2018 Nov 18, 2018

Copy link to clipboard

Copied

LATEST

In fact, there is not any other code! I just use this function to load a pic into the background. The function runs by tap a button. Please test my function on your device and see the result , but becarfull , select a not important pic ! I lose one of my important photos.

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