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 <[email protected]> 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" <[email protected]> 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 ¨¨¨¨¨¨( * ) ( )

