flash - Converting a flex component w/images to bitmap -
I am trying to take images which I am putting in a bitmap of a flex canvas component. I was able to reach that point where I did not get any error, but then no image is visible and the image I save as JPG is empty I think I'm not setting up bitmap data properly I am not able to understand what I am doing.
Here is the code where I am converting it to bitmap:
var imageSnap: ImageSnapshot = ImageSnapshot.captureImage (_renderPop); Var imageByteArray: ByteArray = imageSnap.data byte form; Var bLoader: Loader = new loader (); BLoader.loadBytes (imageByteArray); Var BMD: Bitmapdata = new BitMapData (500,500); Bmd.draw (bLoader); Var imgTest: image = new image (); ImgTest.source = BMD; _renderPop.renderCanvas.addChild (imgTest); Var fileRef: file line = new file reference (); FileRef.save (bLoader, 'testImage.jpg');
_renderPop.renderCanvas is where I am putting images. Is anyone seeing anything wrong?
In your code:
var bLoader: loader = new loader (); BLoader.loadBytes (imageByteArray);
... You are assuming that bytes are being loaded instantly; Try to keep the event listener on the loader as follows:
bLoader.contentLoaderInfo.addEventListener (event.complete, full handler); Private function full handler (event: event): zero {// ... your remaining code goes here}
Load the load-bit function The function is that they are both asynchronous processes so that you need an event listener. It's a bit intuitive, and I myself have made a mistake myself many times.
If that does not work, then maybe leave the contentLoaderInfo property, but should work on top ...
Let me know if you come right Are :)
Comments
Post a Comment