Your problem is that you're calling addChild on the Image component.
This won't work with how the ImageComponent works (or rather SWFLoader,
which is the base class). But the SWFLoader should be able to load a
DisplayObject, if you set that as the source. Also, BTW, you don't need
the URLLoader in your code
So try doing this:
private var loader:FlexLoader = new FlexLoader();
loader.loadBytes (imageByteArray);
previewImage.source = loader;
<mx:Image scaleContent="true" height="260" width="215" id="previewImage"/>
-Doug
Andrew D. Goodfellow wrote:
(I have searched for this answer on the list and in the docs and can't
find anything so I'm gonna go ahead and post. If I missed a previous
post, I apologize, please point me towards it.)
I have an image in a ByteArray and I want to display it within a
specific width and height inside an Image object. Here is my logic:
private var urlloader:URLLoader = new URLLoader();
private var loader:Loader = new Loader();
urlloader.dataFormat = URLLoaderDataFormat.BINARY;
urlloader.data = ByteArray(imageByteArray);
loader.loadBytes (ByteArray(urlloader.data));
var child:DisplayObject = previewImage.addChild(genericLoader);
<mx:Image scaleContent="true" height="260" width="215"
id="previewImage"/>
When it displays it does not scale automatically, it simply displays
at 1:1 of the original ByteArray image. If I set child.width and
child.height to specific values (i.e. 215x260) the Image (or child)
just doesn't display.
I CAN change scale directly or use a Matrix to scale it, but the
problem there is that the child.width and .height are returning 0 so I
can't calculate the correct scale.
Any ideas???
-Andy