在 ArrayCollection 中绑定布尔变量
[Bindable]
public var isToggled:Boolean = true;
public var menuData:Array = [
{label: "Sample", type: "check", toggled: {isToggled}}
];
我试图将 isToggled 变量绑定到切换属性,但收到此错误:1084:语法错误:在点之前需要冒号。也许是因为它将 {isToggled} 视为另一个对象。有解决方法吗?
[Bindable]
public var isToggled:Boolean = true;
public var menuData:Array = [
{label: "Sample", type: "check", toggled: {isToggled}}
];
I'm trying to bind the isToggled variable to the toggled property but I'm getting this error: 1084: Syntax error: expecting colon before dot. Maybe because it is treating {isToggled} as another object. Is there a workaround for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法在 ActionScript 代码中享受声明性数据绑定的优势。仅允许在 MXML 标记内使用。但是您可以使用 MXML 声明您的
Array
或ArrayCollection
:You can't have advantages of declarative data binding within ActionScript code. It is allowed only within MXML tags. But you can declare your
Array
orArrayCollection
with MXML:除非使用 BindingUtils,否则不能在 mxml 外部使用绑定(“{}”)。但是,我也不建议这样做,因为现在您正在复制数据。
为什么需要 2 个布尔值?您已经有了数据,只需使用 menuData 属性绑定它即可。
You can't use bindings ('{}') outside of mxml unless you use BindingUtils. However, I wouldn't recommend that either because now you're copying your data.
Why do you need 2 boolean values? You already have the data just bind it using the menuData property.