Smoothing resized distorted images in flex
Posted By : Dave | Posted At: 2009-04-14 03:41:50

Problem: Images when loaded into flex look blurred, distorted or poor quality.

Solution: Fixing the loaded images using smoothing .

Before Smoothing
After Smoothing

Hi guys , i think we all come across the problem of loading images into flex and disappointed by the way they look blurred or distorted in flex. By default images loaded into flex are not smooth.
I have written a small function that can be called on "complete" event of image loader component and rest you dont need to worry it takes care all . Above picture shows how clean image looks after after applying smoothing code .It even works if the image is zoomed or resized later .

//Mxml starts here
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="absolute" xmlns:local="*" xmlns:asd="asd.*" >
//call this function from where ever you need Image Smoothing .Code by
private function smoothImage(evt:Event):void{
var myBitmap:Bitmap = (( as Image).content as Bitmap);
if (myBitmap != null) {
myBitmap.smoothing = true;
<!--Usage: call complete="smoothImage(event) from image component ) -->
<mx:Image id="myId" source="a.jpg" x="400" width="350" height="350" complete="smoothImage(event)" />
<mx:Image id="img1" source="b.jpg" x="400" y="400" width="300" height="150" complete="smoothImage(event)" />
//mxml ends here


This website focus on: Flash | Flex | FMS | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem,Flash Help,Flash bugs,Flash workaround | Flash Blog | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright � 2008 All rights reserved