Enterprise APP
RadioButtonGroup 속성 이용방법 본문
RadioButtonGroup에서 해당 RadioButton의 속성 값을 가지고 오는 방법 2가지
1. 'itemClick' 이벤트 리스너를 통한 방법(value값만)
import mx.controls.Alert;
import mx.events.ItemClickEvent;
// Event handler function to display the selected button
// in an Alert control.
private function handleCard(event:ItemClickEvent):void {
if (event.currentTarget.selectedValue == "AmEx") {
Alert.show("You selected American Express")
}
else {
if (event.currentTarget.selectedValue == "MC") {
Alert.show("You selected MasterCard")
}
else {
Alert.show("You selected Visa")
}
}
}
]]>
</mx:Script>
<mx:RadioButtonGroup id="cardtype" itemClick="handleCard(event);"/>
<mx:RadioButton groupName="cardtype" id="americanExpress" value="AmEx"
label="American Express" width="150" />
<mx:RadioButton groupName="cardtype" id="masterCard" value="MC"
label="MasterCard" width="150" />
<mx:RadioButton groupName="cardtype" id="visa" value="Visa"
label="Visa" width="150" />
2.'numRadioButtonsChanged' 이벤트를 이용(RadioButton 자체)
mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
initialize="init();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function init():void {
radioGroup.addEventListener("numRadioButtonsChanged", radioGroup_numRadioButtonsChanged);
}
private function radioGroup_numRadioButtonsChanged(evt:Event):void {
var rb:RadioButton = radioGroup.getRadioButtonAt(radioGroup.numRadioButtons-1);
var alert:Alert = Alert.show(evt.toString(), "label:" + rb.label);
alert.status = "numRadioButtons:" + radioGroup.numRadioButtons;
}
]]>
</mx:Script>
<mx:RadioButtonGroup id="radioGroup" />
<mx:HBox>
<mx:RadioButton id="radioButton1" label="Red" group="{radioGroup}" />
<mx:RadioButton id="radioButton2" label="Orange" group="{radioGroup}" />
<mx:RadioButton id="radioButton3" label="Yellow" group="{radioGroup}" />
<mx:RadioButton id="radioButton4" label="Green" group="{radioGroup}" />
<mx:RadioButton id="radioButton5" label="Blue" group="{radioGroup}" />
</mx:HBox>
</mx:Application>
'Flex General > Guide' 카테고리의 다른 글
Flex 챠트관련 자료 (0) | 2010.06.04 |
---|---|
Data Binding issues... (0) | 2010.04.15 |
Handling Data by Flex 3 (0) | 2010.02.15 |
FlexUnit4 (0) | 2010.02.14 |
4 Ways to Automate Flex GUI Testing (0) | 2010.02.10 |
Comments