I need to clone .png image data loaded from server in AS3, so that I am not required to load same data again and again from server.
After a search on cloning image data in AS3 I was able to find following code over internet
clone = new Bitmap(Bitmap(this._loader.content).bitmapData.clone() )
By using this code I am able to clone bitmap data but the problem which I am facing is that my png background is transparent. If I typecast loaded png data to bitmap my icons background becomes white.
Any help would be appreciated.
Hi Laurent & TheDarkIn1978, Thanks a lot for quick revert back and your valuable suggestions,
Let me put complete picture in front of you guys,
I am trying to load icons from server which has to be displayed at several places in same movieclip.
To display image data I have created a movieclip in which I directly add loaded content as its child by calling addChild() function.
Now the problem occurs when I try to add same image data on another movieclip as its chil, new parent of data gets set and this image is removed from previously added content. So at the end this icon is displayed only at one position on movieclip (due to fact that each child can have a single parent).
Therefore I thought to clone image data and display it on screen, when ever Image from server is loaded I call following function to save image data in local,
private var _bmapData : BitmapData;
_bmapData = new BitmapData(_loader.width, _loader.height );
_bmapData.draw( this );
isImageLoaded=true;'
Now whereever I have to show this data , I use to call following code to clone png data
var dup : Image = new Image();
dup.addChild(new Bitmap(_bmapData.clone()));
return dup;
What I beleive transpareny is only supported in png format, not in bitmap or jpeg, therefore my background icons are getting white.
Kindly help as I am stucked and not able to understand my next steps.