반응형
gugudan.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
function gugu(event:Event):void{
var dan:int = int(textinput1.text);
var gugudan:String = "";
for(var i:int=1;i<=9;i++){
gugudan += dan+"x"+i+"="+dan*i+"\n"
}
currentState = "state2";
state2text.text = gugudan;
}
]]>
</mx:Script>
<mx:states>
<mx:State name="state2">
<mx:RemoveChild target="{text1}"/>
<mx:RemoveChild target="{textinput1}"/>
<mx:RemoveChild target="{button1}"/>
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:Text y="2" text="Text" width="86" height="129" horizontalCenter="0" id="state2text" textAlign="center"/>
</mx:AddChild>
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:Button y="133" label="돌아가기" horizontalCenter="0" id="bt_home" click="currentState=''"/>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:Panel width="250" height="200" layout="absolute" horizontalCenter="0" verticalCenter="0" title="구구단테스트" id="panel1">
<mx:TextInput width="26" horizontalCenter="-20" verticalCenter="4" id="textinput1"/>
<mx:Text y="45" text="보고싶은 구구단을 입력한 후 확인을 누르세요." height="19" textAlign="center" horizontalCenter="0" id="text1"/>
<mx:Button x="116" y="73" label="확인" id="button1" click="gugu(event)"/>
</mx:Panel>
</mx:Application>
반응형