Bitmap & BitmapData classes in Actionscript 3.0

本文详细介绍了如何在ActionScript中处理Bitmap与BitmapData实例。包括使用Loader加载图像、创建Bitmap实例的方法、以及传递Bitmap和BitmapData实例时的区别。

  • 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-bitmap


pass BitmapData object:


pass-bitmapdata


download the sourcefile


REFS:


http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d60.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值