简体   繁体   English

Flex 4 XML属性绑定不起作用?

[英]Flex 4 XML Attribute Binding Not Working?

For some reason this seems to no longer work in flex 4, it used to work in flex 3... 出于某种原因,这似乎不再适用于flex 4,它曾用于flex 3 ...

[Bindable]
public var xmlTitle:String = "TEST";

[Bindable]
public var xmlData:XML = <Data title={xmlTitle}> ... </Data>;

I am setting the xmlTitle variable outside of the component: 我在组件外部设置xmlTitle变量:

<local:Comp xmlTitle="Some Title" />

I have tried with getter / setters...etc. 我尝试过getter / setter等等。 It just does NOT update when changing, it shows the default value and never changes. 它只是在更改时不更新,它显示默认值并且永远不会更改。 Is this a known new bug in flex 4? 这是flex 4中一个已知的新bug吗?

I can't say I've ever done that before, mostly because it's extremely bad form. 我不能说我以前做过这件事,主要是因为这是非常糟糕的形式。 If you want to create an xml, using the XML object in mxml to create it in the declarations: 如果要创建xml,请使用mxml中的XML对象在声明中创建它:

<fx:Declarations>
    <fx:XML id="xmlData" xmlns="">
        <Data title="{xmlTitle}">
        </Data>
    </fx:XML>
</fx:Declarations>

Should work just fine. 应该工作得很好。

Using {} with XML in ActionScript is not data binding. 在ActionScript中使用带有XML的{} 不是数据绑定。 It takes current variable's value in the moment of forming XML. 它在形成XML时获取当前变量的值。 And doesn't change it later. 并且以后不会改变它。 So this behavior is absolutely expectable. 所以这种行为是绝对可以预料的。

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

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