Flex - 绑定条件(对于 TextInput 属性文本)
例如
是否可以这样做类似的东西?
For example <s:TextInput id="sd" text="{if () {0} else if() {1} else {2}}"/>
Is it possible to do something like that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用函数来实现您的逻辑:
那么:
如果您在第一个 TextInput 中键入“a”或“b”,则第二个 TextInput 中的值将更改以反映当前状态。
You can use a function to implement your logic:
then:
If you type "a" or "b" in the first TextInput the value in the second will change to reflect the current state.
不;这对于默认的绑定机制来说太复杂了。但是,您没有提供完整的条件,因此很难明确指导您。
当您实现要用作绑定源的属性时,请调度一个事件。在 set 方法中类似这样:
然后添加一个事件监听器:
执行绑定操作
最后,在事件处理程序内部 ; MXML 绑定语法可以;基本上;就像我刚才描述的那样。它稍微复杂一些;但这就是要点。
No; that's too complicated for the default binding mechanism. But, you didn't provide the full condition so it's hard to direct you explicitly.
When you implement the property you want to use as the binding source, dispatch an event. Something like this in the set method:
Then add an event listener:
And finally, perform your binding action in the event handler
Internally; the MXML binding syntax does; basically; something like what I just described. It's slightly more complex; but that is the gist.