- A Bitmap instance has one BitmapData instance as property.
- When you use Loader to load an image, its property 'content' references to the Bitmap object of the loaded image.
- If you have one variable of Bitmap type, you should create it by using 'new Bitmap()', then convet the 'content' to Bitmap and assign it to your variable: _bm = Bitmap($e.target.content); target is referencing to the the loader instance.
- Of course, in some cases you have got the BitmapData instance of the image, then you can simply pass it to Bitmap constructor: _bm = new Bitmap(bitmapdata);
- Bitmap is complex data type, so passing a Bitmap type variable among functions will pass it as reference, that is Actionscript natural feature. And, if you add one Bitmap object to one Sprite, that will result in it be removed from its parent Sprite. So to pass a reference to a Bitmap instance as parameter to function that may add it to Sprite, will not work. See the first picture.
- But if you pass BitmapData instance to a function, and in that function you create a brand new Bitmap using that BitmapData, the BitmapData will be cloned. And that is what you expect. See the second picture.
pass Bitmap object:
pass BitmapData object:
REFS: