简体   繁体   English

Flex MXML绑定与Actionscript绑定

[英]Flex MXML binding vs Actionscript binding

I'm hoping someone can explain what is going on under the hood when using MXML curly bindings. 我希望有人可以解释使用MXML卷曲绑定时幕后发生的事情。

For example, with itemrenderers: 例如,使用itemrenderers:

If I bind some control via MXML to the data source such as: 如果我通过MXML将某些控件绑定到数据源,例如:

text={data.myText} text = {data.myText}

Somehow these bindings seem to get automatically cleaned up. 这些绑定似乎以某种方式会自动清除。

However, if I bind using Actionscript when am I supposed to call unwatch()? 但是,如果我在什么时候使用Actionscript进行绑定,应该调用unwatch()吗? How do I know when the itemRenderer is no longer being used? 我怎么知道什么时候不再使用itemRenderer?

How do the MXML bindings know when to un-bind? MXML绑定如何知道何时取消绑定?

With actionscript, you need to keep an instance of the watcher and clean it yourself. 使用动作脚本,您需要保留一个观察者实例并自己清理它。 The curly braces is essentially a 'shortcut' that creates a lot of extra code to handle binding and clean up after itself (plus making sure it's not in a dependency loop). 花括号本质上是一个“快捷方式”,它创建了许多额外的代码来处理绑定并在其自身之后进行清理(还要确保它不在依赖循环中)。 It's made for convenience while the actionscript version gives you more control, but creates more visible code. 它是为方便起见而制作的,而动作脚本版本则提供了更多控制权,但创建了更多可见代码。

I could go on, but Michael Labriola already has a great talk about the subject. 我可以继续,但是迈克尔·拉布里奥拉(Michael Labriola)已经对该主题进行了精彩的演讲

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM