I haven't used the fl.controls.TileList, but it seems to use a similar strategy that Flex components use: item renderers.
In this case, the documentation for fl.controls.TileList says:
The default cell renderer for this component is the ImageCell class.
An ImageCell cell renderer displays a thumbnail image and a
single-line label. To render a list-based cell in a TileList
component, use the CellRenderer class.
In your case, what you want is to specify a class that will just take a BitMapData
from the dataProvider and use that to display the image.
To use a different class for the renderer, use the TileList
's cellRenderer style.
I haven't created a custom cell renderer for the Flash TileList, but here's some links that may help get you started:
A basic approach to creating your own custom renderer would be something like this:
1. Create a new class that extends CellRenderer:
public class CustomRenderer extends CellRenderer
{
public function CustomRenderer()
{
super();
}
}
2. Override the setter method for the data
property of the CellRenderer
class:
The TileList
component will create a renderer for each element in the dataProvider
. It then calls this setter method on each renderer to pass in the data for that element. In this setter, you can get the BitMapData
and use that to renderer the image. Below is some untested code, there's probably a nicer way to do this (we have nice shortcuts for this type of stuff in Flex)
override public function set data(value:Object):void
{
super.data = value;
if (value != null && value.hasOwnProperty("propertyNameThatContainsBitMapData"))
{
var bmData:BitMapData = value["propertyNameThatContainsBitMapData"] as BitMapData;
if (bmData)
{
var g:Graphics = this.graphics;
g.beginBitMapFill(bmData);
g.drawRect(0,0,100,100); // use whatever dimensions you want
g.endFill();
}
}
}