收到 Flex Bitmap 或 BitmapData 更改的通知吗?
在 Flex 中,如何挂钩位图或位图数据变量,以便每当位图数据发生更改(像素已更改或添加过滤器)时通知函数?
我尝试设置绑定,但不起作用。
一定有办法做到这一点,因为我可以通过“source”属性将 mx:Image 绑定到位图,并且当我修改位图时,显示的图像会一直更新。柔性是如何做到的?它是盲目地在每一帧重绘位图,还是智能地只在位图改变时重绘?如果是这样,它如何知道位图何时发生变化?
In Flex, how does one hook into a bitmap or bitmapdata variable so that a function is notified whenever the bitmap's data has changed (pixel has changed, or filter's been added)?
I tried setting up binding but it doesn't work.
There must be a way to do it, because I can bind an mx:Image to a bitmap via the 'source' attribute, and the displayed image updates all the time when a I modify the bitmap. How does flex do it? Does it blindly redraw the bitmap at every frame, or is it smart and only redraws when the bitmap changes? If so, how does it know when the bitmap changes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这只是一种半有根据的猜测,没有经过任何测试,所以请谨慎对待。
当Flex绑定
Image
的source属性时,.source
的值是BitmapAsset
类型。BitmapAsset
有一个.bitmapData
属性,它是对相关位图的引用。我预计 Flex 完成的绑定是针对
.bitmapData
属性的。我不明白你有什么理由不能这样做。不过,我认为您必须做一些循环工作,因为您必须创建一个 BitmapAsset 实例并用您想要保留选项卡的 BitmapData 填充它打开,然后绑定到
BitmapAsset
对象的.bitmapData
属性。假设有一个名为“bitmapData”的变量,它是 BitmapData 的一个实例,我认为以下内容应该有效。
This is just sort of a semi-educated guess, with no testing behind it, so take it with some salt.
When Flex binds the source attribute of an
Image
, the value of.source
is of typeBitmapAsset
.BitmapAsset
has a.bitmapData
property, which is a reference to the bitmap in question.I expect that the binding done by Flex is against that
.bitmapData
property.I don't see any reason why you shouldn't be able to do that, too. I think you'd have to do a little circular work, though, as you'd have to create a
BitmapAsset
instance and populate it with theBitmapData
you want to keep tabs on, then bind to the.bitmapData
property of theBitmapAsset
object.Assuming a var called 'bitmapData', which is an instance of
BitmapData
, I think the following should work.