0

If using {result} instead of {this.result}, the binding mechnism can't work. I didn't find any doc describing the thing. I am using Flex3.5. Do you know the reason?

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
    <mx:Script>
        <![CDATA[       
            [Bindable]
            public var result:String ="b";

            function confirm():void{
                result = "changed text";
            }
        ]]>
    </mx:Script>
    <mx:TextInput text="{this.result}"/>
    <mx:Button label="Confirm" buttonDown="{confirm();}"/>
</mx:Panel>
4

1 回答 1

1

这不是绑定的问题。据我所知,您应该避免使用“结果”作为变量名,因为它是由组件使用的。如果将 result 重命名为 result1,则无论“this”关键字如何,它都可以正常工作。

要查看“result”和“this.result”之间的区别,您可以尝试将“result”变量定义为静态变量。它看起来像这样:

在此处输入图像描述

因此,如果某个变量存在不确定性,“this”表示它是一个成员变量,而不是静态变量。

此表达式还可以显示两个变量之间的差异:

<mx:TextInput text="{this.result === result}"/>

在你的情况下它返回 false 。

于 2013-05-25T20:31:41.997 回答