简体   繁体   中英

Flex: Show image in BitmapImage (flex 4.5) from property Object?

I need to show an image stored in a database. I'm mapping a C# class Digital, with a field public Byte[] Imagen, to an AS3 class Digital, with a property public Imagen:Object/ByteArray. I'm using Fluorinefx as broker.

I'm trying with s:BitmapImage, assigning .source=Imagen, but graphic doesn't appear.

Do I need to convert in some way the Imagen propery to be able to assign the BitmapImagen's source??

I'm using flex 4.5. Any help I'll appreciate.

Edit:

Debugging, the real error is:

TypeError: Error #1034: Type Coercion failed: cannot convert []@e49c629 to flash.utils.ByteArray.

This is the real problem, maybe an issue with Fluorinefx?

Ok, this is how I workaround this, apparently exists some issue with Fluorine's C# byte[] type processing; something bad happens with this mapping: (AS3)ByteArray <== byte[] (C#).

Refering to this answer from Pedro Cruz , I had to create another field in C# Digital class:

FluorineFx.AMF3.ByteArray ImagenPresentation;

and use the BytesToByteArray suggested function to return this correct type (FluorineFx.AMF3.ByteArray) from the ImagenPresentation get property:

get 
   { 
        return BytesToByteArray(Imagen);
   }

Finally, this new field is mapped to ImagenPresentation:ByteArray in AS3.

Kind a mess, but works!.. maybe this can help anyone else, thanks a lot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM