LOL! Nevermind. I figured out what the issue was. I was using coldfusion on
the backend, and when loading the byteArray into my model Object prior to
passing it back to Flex, I was using the ToString(*).getBytes() to grab a
byte array. Somehow this was causing issues. Removing that and just keeping
directly what is pulled from the database relieved me of my issues.

Thanks for your input Alex. Your response caused me to take a closer look at
what was happening prior to loading into Flex since it was obvious it should
just work on the flex end of things.



On Tue, Apr 13, 2010 at 9:54 AM, Amanda Machutta <amachu...@gmail.com>wrote:

> Yes this is what I assumed as well, but even after verifying the position
> of 0, its still loading a broken image icon.
>
>
> On Tue, Apr 13, 2010 at 12:58 AM, Alex Harui <aha...@adobe.com> wrote:
>
>>
>>
>> If it is really a PNG file, you should just be able to assign the
>> bytearray directly to the source, but be sure you’ve set the bytearray’s
>> position=0 before doing so.
>>
>>
>>
>> On 4/12/10 4:27 PM, "Amanda Machutta" <amachu...@gmail.com> wrote:
>>
>>
>>
>>
>>
>>
>> Hey All,
>>
>> I’m trying desperately to load an image into flex from a byteArray and for
>> the life of me I cannot seem to get it to work. I have code that uses a
>> FileReference to browse for a *.png file, and then on completion it will set
>> the img.source = fileReference.data. This works great! The
>> fileReference.data is in the form of a byteArray.
>>
>> I then use a RemoteObject to save that byteArray to the database using
>> Coldfusion. That part works perfectly as well.
>>
>> I can the retrieve the byteArray, pass it back to flex, verify that all
>> the properties of the byteArray are exactly the same as the properties were
>> when the image worked, and then assign it to the img.source, and I get a
>> broken image.
>>
>> if I do this:
>> if(this.chat_queue.company_logo.length > 0){
>> var _loader:Loader = new Loader();
>> _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,function(e:Event):void
>> {
>> this.imgLogo.source = e.currentTarget.content;
>> });
>> _loader.loadBytes(new
>> PNGEncoder().encodeByteArray(this.chat_queue.company_logo,90,43));
>> }
>>
>> Then I get “Error 2030: End of file was encountered.”
>>
>> If I try this:  }
>> if(this.chat_queue.company_logo.length > 0){
>> var _loader:Loader = new Loader();
>> _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,function(e:Event):void
>> {
>> this.imgLogo.source = e.currentTarget.content;
>> });
>> _loader.loadBytes(this.chat_queue.company_logo);
>> }
>>
>> Then I get “Error #2124: Loaded file is an unknown type.”
>>
>>
>>
>> And if I just simply do this:
>>
>> this.imgLogo.source = this.chat_queue.company_logo;
>>
>> I get a broken image without error.
>>
>>
>>
>> Keep in mind that this.chat_queue.company_logo is a byteArray, and is
>> stored in the database as a blog.
>>
>>
>>
>> Thanks,
>>
>> I’m at my wits end. Any help would be greatly appreciated.
>>
>>
>> --
>> Alex Harui
>> Flex SDK Team
>> Adobe System, Inc.
>> http://blogs.adobe.com/aharui
>>
>>  
>>
>
>
>
> --
>    ´¨)                                               __o
>  .·´  .·´¨)    ¸.·´¨)                              _'\< .
> (¸.·´     (¸.·´     (¸.·´¨¨  Amanda ¨¨¨¨¨¨( * )  (   )
>



-- 
   ´¨)                                               __o
 .·´  .·´¨)    ¸.·´¨)                              _'\< .
(¸.·´     (¸.·´     (¸.·´¨¨  Amanda ¨¨¨¨¨¨( * )  (   )

Reply via email to