display image using byteArray failed (Unhandled IOErrorEvent:. text=Error #2124:Loaded file is an unknown type)-Collection of common programming errors

Problem:can’t display jpeg image when using the byteArray as source.

suppose there is an existing image named “card”.. Here is the scenario:

1.get bitmapData: var bitmapData:BitmapData = Bitmap(card.content).bitmapData

2.get byteArray: var pixels:ByteArray = bitmapData.getPixels(bitmapData.rect)

3.attach the byteArray to an new Image: var another:Image = new Image(); another.source = pixels.

(I also tried to use another way, still can’t work: var loader:Loader = new Loader(); loader.loader(pixels);) loader.loader(pixels) will throw an error! *The error is “Unhandled IOErrorEvent:. text=Error #2124”:Loaded file is an unknown type*