태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.

  




 
FLEX Builder 3를 설치하고 간단하게 계산기를 만들어 보았다...
만들면서 계속 드는 생각이 "플렉스, 이건 머지?".....

비주얼 스튜디오에서 C#으로 개발하는것처럼 편리하고
상당히 매력적인것 같다.. ^^; 



[소스]

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
 <![CDATA[
 
 /*
  2009.10.04 Flex 계산기  By OP.Park..
  연속으로 계산하는 과정에서 오류가 좀 있음...
  플렉스를 처음 공부하면서 간단하게 만들어본 윈도우계산기..
  비쥬얼스튜디오로 C#을 이용해서 개발하는것과 너무 흡사하다..
 */
 
 var temp:int=0, temp2:int=0, total:int=0;
 var disp:String="";  var sign:String="";
 
 
 //부호에 따른 계산
 public function sign_Calc():void{
  temp2=int(disp);
  
  if(sign=="+"){
   total = temp + temp2;
   disp = String(total);
   show.text = disp;
  }
  else if(sign=="-"){
   total = temp - temp2;
   disp = String(total);
   show.text = disp;
  }
  else if(sign=="*"){
   if(temp==0){
    temp=1;
   }
   total = temp * temp2;
   disp = String(total);
   show.text = disp;
  }
  else if(sign=="/"){
   if(temp==0){
    temp=1;
   }
   total = temp / temp2;
   disp = String(total);
   show.text = disp;
  }
  
  sign=""; //"="을 계속 선택했을때 계속 계산되는것을 방지
 }
 
 //+,-,*,/ 설정
 public function plus():void{
  sign_Calc();
  temp = int(disp);
  disp="";
  sign="+";
  
 }
 
 public function min():void{
  sign_Calc();
  temp = int(disp);
  disp="";
  sign="-";
 }
 
 public function div():void{
  sign_Calc();
  temp = int(disp);
  disp="";
  sign="/";
 }
 
 public function mult():void{
  sign_Calc();
  temp = int(disp);
  disp="";
  sign="*";
 }
 
 public function init():void{
  disp="";
  temp=0;
  temp2=0;
  total=0;
  show.text="0";
 }
 
 
 //숫자 키패드 입력
 public function In_1():void{
  disp = disp + "1";
  show.text = disp;
 }
 
 public function In_2():void{
  disp = disp + "2";
  show.text = disp;
 } 
  
 public function In_3():void{
  disp = disp + "3";
  show.text = disp;
 } 
 
 public function In_4():void{
  disp = disp + "4";
  show.text = disp;
 }
 
 public function In_5():void{
  disp = disp + "5";
  show.text = disp;
 }
 
 public function In_6():void{
  disp = disp + "6";
  show.text = disp;
 }
 
 public function In_7():void{
  disp = disp + "7";
  show.text = disp;
 }
 
 public function In_8():void{
  disp = disp + "8";
  show.text = disp;
 }
 
 public function In_9():void{
  disp = disp + "9";
  show.text = disp;
 }
 
 public function In_0():void{
  disp = disp + "0";
  show.text = disp;
 }
 
 public function link_Url():void{
  var urlRQ:URLRequest = new URLRequest();
  
  urlRQ.url = "http://singblog.net/285";
  navigateToURL(urlRQ, "_new");
 }
 
 ]]>
</mx:Script>
 <mx:Panel y="98" width="212" height="231" layout="absolute" title="Flex 계산기 " horizontalAlign="center" id="Flex_Calc" horizontalCenter="-5">
  <mx:TextInput x="5.75" y="10" width="181" id="show" textAlign="right" text="0"/>
  <mx:Grid x="5.5" y="38" width="181.5" height="148">
   <mx:GridRow width="100%" height="100%">
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="7" width="39" height="32" id="input_7" click="In_7();"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="8" width="39" height="32" id="input_8" click="In_8();"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="9" width="39" height="32" click="In_9();" id="Input_9"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="/" width="39" height="32" id="Input_div" click="div();"/>
    </mx:GridItem>
   </mx:GridRow>
   <mx:GridRow width="100%" height="100%">
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="4" width="39" height="32" click="In_4();" id="Input_4"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="5" width="39" height="32" click="In_5();" id="Input_5"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%" label="In_6;">
     <mx:Button label="6" width="39" height="32" id="Input_6" click="In_6();"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="*" width="39" height="32" id="Input_Mult" click="mult();"/>
    </mx:GridItem>
   </mx:GridRow>
   <mx:GridRow width="100%" height="100%">
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="1" width="39" height="32" click="In_1();" id="Input_1"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="2" width="39" height="32" click="In_2();" id="Input_2"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="3" width="39" height="32" click="In_3();" id="Input_3"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="-" width="39" height="32" id="Input_Min" click="min();"/>
    </mx:GridItem>
   </mx:GridRow>
   <mx:GridRow width="100%" height="100%">
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="0" width="39" height="32" click="In_0();" id="Input_0"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="C" width="39" height="32" click="init();" id="Input_Init"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="=" width="39" height="32" click="sign_Calc();" id="Total_Calc"/>
    </mx:GridItem>
    <mx:GridItem width="100%" height="100%">
     <mx:Button label="+" width="39" height="32" id="Input_Plus" click="plus();"/>
    </mx:GridItem>
   </mx:GridRow>
  </mx:Grid>
 </mx:Panel>
 <mx:LinkButton y="334" label="http://singBlog.net/285" enabled="true" id="link" click="link_Url();" fontWeight="normal" horizontalCenter="-4"/>
</mx:Application>



'프로그래밍 > FLEX' 카테고리의 다른 글

JSP에 FELX 삽입하기...  (0) 2009/10/08
FLEX로 만든 계산기  (0) 2009/10/04
Hello Flex!!...  (0) 2009/10/03
Flex Builder 3 설치..  (0) 2009/10/03

YOUR COMMENT IS THE CRITICAL SUCCESS FACTOR FOR THE QUALITY OF BLOG POST