Flex core ByteArray Image
var myFile:File = new File("./test.jpg");
var myFileStream1:FileStream = new FileStream();
myFileStream1.open(myFile, FileMode.READ);
var byte:ByteArray = new ByteArray();
myFileStream1.readBytes(byte,0,byte.bytesAvailable);
myFileStream1.close();
now how can i add a byte variable to the canvas? for example var canvas: Canvas = new Canvas (); canvas.addChild (byte); is it possible to add a ByteArray to the canvas?
I disabled this with no image control. I used decoder concept. Here's one below: It worked.
loader.loadBytes(eizo.idolImage);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
function (e:Event):void {
var bmpData:BitmapData = new BitmapData(loader.width, loader.height);
bmpData.draw(loader);
var ui:UIComponent = new UIComponent();
ui.addChild(new Bitmap(bmpData));
canvas0.addChild(ui);
}
);
No, you cannot. This is due to the fact that it ByteArray
itself cannot be displayed, since the Flash Player does not know what it is.
In your case, you are going to display the "test.jpg" image on Canvas
, right? You can just set the Image
control property source
to the loaded object ByteArray
and add it to Canvas
. Cm. http://livedocs.adobe.com/flex/3/langref/mx/controls/Image.html
source to share