12-03-2012 01:20 PM
I've run into an issue trying to update a qnx.fuse.ui.display.Image's bitmapData:
here's my code:
function update( bmp:Bitmap ):void
{
var bmd:BitmapData = bmp.bitmapData; if ( bmd is BitmapData ) { trace( _image.width, "x", _image.height, bmp.name, bmd.width, "x", bmd.height ); _image.setImage( bmd ); _image.visible = true;
and here's the trace output:
329 x 256 instance1872 341 x 256 ArgumentError: Error #2015: Invalid BitmapData. at flash.display::BitmapData/get width() at qnx.fuse.ui.display::Image/getRawPreferredSize()[E:\hudson\workspace\BB10_0_09-AIR_SDK_API\src\qnxui \src\qnx\fuse\ui\display\Image.as:142] at qnx.fuse.ui.display::Image/setImage()[E:\hudson\wo rkspace\BB10_0_09-AIR_SDK_API\src\qnxui\src\qnx\fu se\ui\display\Image.as:337]
The new bitmapData seems to be ok, since height and width are non-zero, so it seems to be accessing a previous bitmapData instance (which has been replaced).
I've tried keeping a global reference to the old bitmapData, but same result...
Suggestions please...
Solved! Go to Solution.
12-03-2012 01:47 PM
12-03-2012 01:48 PM
12-03-2012 01:54 PM
Yes, I'm aware of the delay, hence the test to see if the bitmapData is set.
The images are being loaded from and external server by my ImageLoader and cached in an ImageCache. The update function gets called when we get Event.COMPLETE.
In the problematic case, the original bitmapData in the cache has been reloaded with a new bitmapData instance.
Regards
12-03-2012 02:35 PM
to resolve the problem I added the following:
if ( _image.bitmapData )
{
try
{
var testWidth:int = _image.bitmapData.width;
}
catch( e:Error )
{
var index:int = getChildIndex( _image );
trace( "remove image at:", index, _image.x, _image.y, _image.hAlign, _image.vAlign );
removeChildAt( index );
_image = new Image();
{
_image.fixedAspectRatio = true;
}
addChildAt( _image, index );
invalidateDisplayList();
}
}
_image.setImage( bmd );ugly, but necessary...