Yordan Yanakiev
Yordan Yanakiev

Reputation: 2604

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.

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

Upvotes: 1

Views: 1478

Answers (2)

Yordan Yanakiev
Yordan Yanakiev

Reputation: 2604

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"

Upvotes: 1

shaunhusain
shaunhusain

Reputation: 19748

Best guess is that your binding isn't triggering an update, try assigning the property directly

cameraSource.source = bmp; //at the end of onComplete

Either this or the container for the BitmapImage is constraining it's size, you could also try setting a literal explicit pixel size temporarily instead of a percent.

Upvotes: 2

Related Questions