无法绑定到变量

时间:2010-06-11 01:22:37

标签: flex

                          

            import server.valueObjects.Data;

            [Bindable] 
            public var dbl:Number;
            [Bindable]
            public var val:String;


            public function clientMonitor():void{
                var callResp:CallResponder = new CallResponder();
                callResp.addEventListener(ResultEvent.RESULT, monitorResult);
                callResp.addEventListener(FaultEvent.FAULT, monitorFault);
                callResp.token = plcServiceBean.getMonitorData();
            }

            public function monitorResult(event:ResultEvent):void{
                dbl = event.result.value as Number;
                val = dbl.toString();
                trace (dbl);
                trace(val);
            }

            protected function monitorFault(event:FaultEvent):void{
                Alert.show(event.fault.faultString, "Error while monitoring Data ");
            }
        ]]>
    </fx:Script>
    <s:layout>
        <s:VerticalLayout horizontalAlign="contentJustify" />
    </s:layout>

    <fx:Declarations>
        <plcservicebean:PlcServiceBean id = "plcServiceBean" 
                                       showBusyCursor="true" 
                                       fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"/>
    </fx:Declarations>
    <mx:Form height="103">
        <mx:FormItem label="View" x="2" y="11">
            <s:TextInput id = "view1"
                         text="{val}"/>
        </mx:FormItem>
    </mx:Form>
</s:Panel>

这里的方法clientMonitor()在来自主应用程序的creationcomplete()上调用。

我无法将Bindable变量dbl绑定到我的textInput。使用调试器,我能够看到结果已成功分配给变量dbl,但它无法将其绑定到view1的文本。我看到在view1的文本中显示了一个NaN。

-H

1 个答案:

答案 0 :(得分:2)

您正在尝试将数字绑定到字符串。尝试使类型相同,看看是否有效果。