H P
H P

Reputation: 27

Unable to bind to a variable

            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>

Here the method clientMonitor() is called on creationcomplete() from the main application.

I am not able to bind the Bindable variable dbl to my textInput. Using the debugger, I am able to see that the result is assigned successfully to variable dbl, but it is not able to bind it to the text of view1. I see a NaN displayed in the text of view1.

-H

Upvotes: 0

Views: 428

Answers (1)

JeffryHouser
JeffryHouser

Reputation: 39408

You're trying to bind a Number to a String. Try making the types the same and see if that has an effect.

Upvotes: 2

Related Questions