In my flex app there’s an item renderer for a TileList that I am using.
I load the image into the Item Renderer at runtime. I am using the following code to resize the image width and height. But it doesn’t seem to be working.
I debugged the flex app and find that the actual width and height values are getting assigned. But the image never looks the right size.
Here’s my code:
private function Init() :void
{
tileImg = new Image();
tileImg.source = data.ICON;
tileImg.toolTip = data.TITLE;
tileImg.buttonMode = true;
tileImg.addEventListener(Event.COMPLETE, AdjustImageDimensions);
this.addChild(tileImg);
}
private function AdjustImageDimensions(e:Event):void
{
tileImg.width = (e.currentTarget as Image).contentWidth;
tileImg.height = (e.currentTarget as Image).contentHeight;
}
Ok, I had a problem just like this the other day and I fixed it by using the Loader class. You can grab the information after the file has been loaded. You need an event listener attached to the loader as well. Where are you getting the image from anyways? A URL or a FileSystem?
Here is a quick example:
{
import flash.display.Loader;
import flash.events.Event;
import flash.net.FileReference;
}
hope that helps