Scott
Scott

Reputation: 17057

Have Image bind to bytearray rather than bitmapasset or bitmap

I have an object that stores the compressed ByteArray version of an image (jpg or png). I want to keep it that way as the bytearray is about 30x smaller than the Bitmap it creates. The problem I run into is when I want to bind an image to this byte array. I can't really bind it to bytearray, because it requires a BitmapAsset as a source. Is there a way I can load a BitmapAsset from a bytearray but still bind to the bytearray when a new image is available?

Upvotes: 0

Views: 841

Answers (1)

Scott
Scott

Reputation: 17057

Ok, so looks like I may have misspoke about assigning a byte array to the source. It looks like this does work and binding to a bytearray will work.

<?xml version="1.0" encoding="utf-8"?>
<mx:Image xmlns:mx="http://www.adobe.com/2006/mxml"
     source="{imagePM.test}">
    <mx:Script>
        <![CDATA[
            import com.pinkhippo.model.presentation.ImageViewerPM;

            [Bindable]
            public var imagePM:ImageViewerPM;

        ]]>
    </mx:Script>
</mx:Image>

[Bindable]
public class ImageViewerPM extends EventDispatcher{

     public var test:ByteArray;
}

Upvotes: 1

Related Questions