actionscript-3loadbitmapdatatilelist

load bitmapData into TileList AS3


say I have a bitmap on my stage, and I want to load this bitmap into TileList component. But TileList's dataProvider requests URL links to be passed as a parameter but not bitmapData. How would I do that?

NOTE: I'm loading the bitmapdata from Sqlite database, in which it's stored as byteArray. Oh and I'm using AIR.


Solution

  • You can pass a DisplayObject as the source parameter of a TileList item's. If you have a BitmapData quickest option would be to pass a Bitmap object containing that bitmapData:

    for(var i:int = 0 ; i < 10; i++) t.addItem({label:'item '+(i+1),source:new Bitmap(new YourBitapData())});
    

    If you want to do the custom cell renderer route, you can do also do that. The main problem is the UIComponent's getDisplayObjectInstance() method doesn't cater for BitmapData. I imagine you could subclass ImageCell and make the changes needed:

    The simpler, the better though, so I'd recommend trying my 1st suggestion.