このコードをMXML
アプリケーションに入れて実行します..
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="567" height="206" minWidth="955" minHeight="600" initialize="application1_initializeHandler(event)">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
protected function application1_initializeHandler(event:FlexEvent):void
{
}
protected function rd1_clickHandler(event:MouseEvent):void
{
if(!t1.enabled)
{
t1.enabled=true;
}
else if(t1.text=="" && t1.enabled)
{
Alert.show("Value is required in text box");
}
else
t1.enabled=true;
}
protected function rd2_clickHandler(event:MouseEvent):void
{
t1.text=null
t1.enabled =false;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TextInput x="132" y="41" id="t1"/>
<s:RadioButton x="162" y="91" label="Yes" id="rd1" groupName="select" click="rd1_clickHandler(event)"/>
<s:RadioButton x="211" y="91" label="No" id="rd2" groupName="select" click="rd2_clickHandler(event)" />
<s:Label x="79" y="45" text="Name"/>
</s:Application>