I create components for image resizing.
Image will be resized if it don't fit to area.
Maybe you can place it inside your item renderer.
Hope it will help.
package
{
import flash.display.Bitmap;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.net.URLRequest;
import mx.core.UIComponent;
public class ImageLoader extends UIComponent
{
public function ImageLoader()
{
super();
}
protected var bitmap:Bitmap;
protected var _source:String;
protected var _originalWidth:Number;
protected var _originalHeight:Number;
[Inspectable(type=String)]
public function set source(value:String):void
{
if(_source!=value && value!=null && value!="" &&
value!=undefined)
{
_source=value;
updateSource();
}
}
public function get source():String
{
return _source;
}
protected function updateSource():void
{
if(bitmap!=null && bitmap.bitmapData!=null)
{
bitmap.bitmapData.dispose();
}
while(this.numChildren>0)
{
this.removeChildAt(0);
}
var loader:Loader=new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT,onImageInit);
loader.load(new URLRequest(_source));
}
protected function onImageInit(event:Event):void
{
if(LoaderInfo(event.currentTarget).content is Bitmap)
{
bitmap=LoaderInfo(event.currentTarget).content as Bitmap;
_originalWidth=bitmap.bitmapData.width;
_originalHeight=bitmap.bitmapData.height;
this.addChild(bitmap);
update();
}
}
protected var _width:Number=0;
protected var _height:Number=0;
protected override function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth,unscaledHeight);
this._width=unscaledWidth;
this._height=unscaledHeight;
update();
}
protected function update():void
{
if(bitmap!=null)
{
if(_originalWidth>_width || _originalHeight>_height)
{
var k:Number=_width/_originalWidth;
if(k*_originalHeight>_height)
{
k=_height/_originalHeight;
}
bitmap.width=_originalWidth*k;
bitmap.height=_originalHeight*k;
}
bitmap.x=(_width-bitmap.width)/2;
bitmap.y=(_height-bitmap.height)/2;
}
}
}
}
<ns2:ImageLoader width="300" height="300" source="Winter.jpg" x="70"
y="271"/>