
Clone an Image in Flex (with flash.display.Loader)
Submitted by admin on Mon, 01/10/2011 - 18:10
One could think that Adobe's developers have already come up with a standard method to clone images by now. But NO - Nothing comes without a headache in Flash... The solution is to get hold of the bitmapData. In case you are using a Loader Class to load the image, the loader.content can be casted to a Bitmap Class Object. This Bitmap holds the raw bitmapData which can now be cloned:
Method:
var bitmap:Bitmap; bitmap = this._loader.content as Bitmap; this.originalWrapper.rawChildren.addChild(bitmap); // clone the image var clone:Bitmap; clone = new Bitmap(Bitmap(this._loader.content).bitmapData);
Hurray! We managed to copy one pixel array to another :-)
Example:
This content requires Adobe Flashplayer
View Source is enabled
- Login to post comments