Smoothing Dynamically Loaded Images in AS3

If you dynamically load images via actionscript and try to scale them, they become jagged. To fix this, you’ll have to set smoothing to true via code in AS3.

This example assumes you have an image named “photo.jpg” in the same directory as your flash file.

var imgLoader:Loader = new Loader();
	imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);
	imgLoader.load(new URLRequest("photo.jpg"));
function loadProdComplete(e:Event):void {
	var bit:Bitmap = e.target.content;
	if(bit != null)
	bit.smoothing = true;
	thumb_mc.addChild(e.target.content);
}

Also note if you images are not dynamically loaded, and are stored in the library, you can simply check the box to ‘Allow smoothing’ via the bitmap properties panel.

One Response

  1. Pingback: as3 smoothing loaded image « MisterSaisho.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Next Post » »