【发布时间】:2014-08-04 08:10:01
【问题描述】:
我有一个用 flex 动作脚本编写的代码,我正在尝试使用 selectedValue 将变量绑定到 RadioButtonGroup
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
[Bindable]
public static var appObj:String = "first";
public function setToThird():void {
appObj = "third";
}
public function setToFirst():void {
appObj = "first";
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:RadioButtonGroup id="travelGroup" selectedValue="{appObj}"/>
</fx:Declarations>
<s:RadioButton x="167" y="91" label="first" group="{travelGroup}"/>
<s:RadioButton x="167" y="119" label="second" group="{travelGroup}"/>
<s:RadioButton x="167" y="151" label="third" group="{travelGroup}"/>
<s:Label x="195" y="177" text="appObj value is {appObj}" />
<s:Button x="149" y="277" label="setToThird" click="setToThird()"/>
<s:Button x="270" y="277" label="setToFirst" click="setToFirst()"/>
</s:WindowedApplication>
当我点击setToThird button 时,appObj value 将设置为字符串third,而选中的单选按钮将是third。
现在,当我单击 second 单选按钮时,appObj 的值仍然是字符串 third,单击按钮 setToThird 不会将单选按钮选择更改为 third 作为值 @987654331 @ 没有改变,绑定 (Bindable) 不会被调用。
谁能帮助我了解如何使用 BindingManager 或其他工具手动调用绑定。
我不想实现双向数据绑定。
【问题讨论】:
标签: actionscript-3 flash apache-flex air flash-builder