How do I insert a variable in MXML (Flash builder 4)?
I have a text box that receives data from XML. Has activated the service. Everything works fine if i use "taurus" instead myVar in {}. Now I want to change the field and depending on the button is pressed to receive different data. But nothing comes out.
public var myVar:String = "taurus";
protected function t1_creationCompleteHandler(event:FlexEvent):void
{
getDataResult.token = lov.getData();
}
protected function b1_clickHandler(event:MouseEvent):void
{
var myVar:String = "aries";
getDataResult.token = lov.getData();
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getDataResult"/>
<lov:Lov id="lov" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
</fx:Declarations>
<s:TextArea x="10" y="146" width="179" h开发者_如何学运维eight="89" id="t1" text="{getDataResult.lastResult.myVar.yesterday}"/>
<s:TextArea x="10" y="257" width="179" height="89" id="t2" text="{getDataResult.lastResult.taurus.today}"/>
<s:Button x="10" y="27" label="Aries" id="b1" click="b1_clickHandler(event)"/>
Not entirely sure what your question is, but are you trying to change a label in the UI based on the button click? If so, you'll want to add [Bindable] above your declaration of myVar.
If this another value suppose to be "aries", than you've been doing it wrong. You've defined new myVar
variable where you should've only change its value.
This line defines new variable for the current scope:
var myVar:String = "aries";
This line changes the value of an existing variable:
myVar = "aries";
精彩评论