Search code examples
actionscript-3apache-flexairflex4.5

BitmapImage and Image components does not display loaded bitmap?


[Bindable]
protected var bmp : Bitmap = new Bitmap();
...

var loader : Loader = new Loader();
    loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onComplete );
    loader.load( new URLRequest( fileObj.url ) );

function onComplete( event : Event ) : void
{
    trace( Bitmap( LoaderInfo( event.target ).content ).bitmapData.height );

    bmp = ( new Bitmap( Bitmap( LoaderInfo( event.target ).content ).bitmapData ) ) ;

}
...

<s:BitmapImage id="cameraSource" width="100%" height="100%" source="{ bmp }" scaleMode="stretch" />

I am using this source code to load a localy stored image file. It is loaded fine, but due some reason is not displayed.

  • Why the follow source code doesn't display the loaded image ?

// Flex 4.6 and Flex 4.8 tested, mobile AIR application


Solution

  • Seems like It is my fault of not sufficient explaining the situation. The whole thing is moved into a View, but once a browse for picture view is been pushed, it is destroying the data into current view.

    The follow row of code is fixing everything

    destructionPolicy="never"