[03-D1] Flex3 API Document, Debug, ActionScript 3.0 개론

[01] Flex3 API Document
     - http://livedocs.adobe.com/flex/3/langref/package-summary.html

    
1. import 문의 사용
   - control과 관련된 Package
     http://livedocs.adobe.com/flex/3/langref/mx/controls/package-detail.html

   - 사용할 클래스나 인터페이스의 위치 지정
     import mx.controls.Alert;





2. Debug
   - Flash Player Debugger Version 설치
     . http://www.adobe.com/support/flashplayer/downloads.html
     . IExplorer: Windows Flash Player 10 ActiveX control content debugger (for IE) (EXE, 2.12 MB)
     . Firefox  : Windows Flash Player 10 Plugin content debugger (for Netscape-compatible browsers) (EXE, 2.09 MB)

   - trace함수의 사용
     var len:int = pass.length;
     trace("길이: " + len);

   - Debugger모드로 실행: 값을 입력하는등 조작을 해야 출력됨.
     
   - 실습: 

>>>>> src/debugExam.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
                creationComplete="init()" width="301" height="344">
    <mx:Script>
        <![CDATA[
        
            import mx.controls.Alert;
            
            public function init():void{
                trace("init 함수 호출");
                txaPanel.text = "";
                
                // for문을 2개 사용하여 각각의 for문의 인수가 같으면
                // 출력되지 않는 스크립트를 작성하세요.
                var i:int = 0;
                var j:int = 0;
                var str:String = "";
                
                for (i=0; i<=2; i++){
                    for (j=0; j<=2; j++){
                        if ( i == j ){
                            trace("i=" + i + ", " + "j=" + j);
                            continue;
                        }
                        str = str + ("i=" + i) + " " + ("j=" + j) + "\n";
                    }
                }
                txaPanel.text = str;
            }
        ]]>
    </mx:Script>
    <mx:TextArea x="20" y="10" width="261" height="288" fontSize="20" id="txaPanel" text="txaPanel"/>
    <mx:Button x="62" y="306" label="함수실행" fontSize="12" id="btnExecute" 
               click="init()"/>
    <mx:Button x="148" y="306" label="내용 지우기" fontSize="12" id="btnDelete" 
               click="txaPanel.text ='' "/>

</mx:Application>






[02] ActionScript 3.0 개론
     - ActionScript 2.0에서는 데이터 타입을 명시하지 않았으나
       3.0은 데이터 타입을 명시해야 합니다.
       public var kuk:int;
     - ActionScript 3.0은 AVM2에서 실행되며 Flash Player9에는 AVM1, AVM2가 함께 
       설치되어 있습니다. ActionScript 2.0은 AVM1을 사용합니다.
     - ActionScript 2에서는 모든 콤포넌트가 무거운 MovieClip의 하위 클래스를 상속받아
       구현되었으나 3.0에서는 좀더 가벼운 Sprite 클래스를 기초로 콘트롤이 만들어져 있습니다.
     - ActionScript API Document참조시 'Language Reference only'를 반드시 체크하고 검색하세요.


1. 변수
   - 숫자로 시작 할 수 없습니다.
   - 특수 문자는 사용할 수 없습니다.
   - ActionScript 명령어는 사용할 수 없습니다.
   - 다른 언어와 다르게 데이터 타입을 변수의 뒤에 선언합니다.
   
   선언 예) public var name:String; 




2. 변수 접근 제한자
   - internal(default): 같은 패키지 내에서만 접근 가능
   - private: 같은 클래스내에서만 접근 가능
   - protected: 같은 클래스 및 상속한 클래스에서만 접근 가능
   - public: 모든 클래스에서 접근 가능
     예) public var ret:Boolean = true;
         private var name:String = "홍길동";




3. 상수
   - 값을 지정하면 변경 할 수 없습니다.
     예) const week:int = 7;




4. 데이터 타입
   - Boolean: true, false
   - int    : -2^31 ~ 2^31-1
   - Number : 1.79769E+308 ~ 4.94065E-324
   - Object : 객체 형식
   - String : UTF-16
   - uint   : 0 ~ s^32-1
   - void   : 리턴 값 없음
   - *      : 모든 데이터 타입을 말함




5. MXML에서의 ActionScript 사용
   - [new -- ActionScript File]

   - eclipse project: Flex Project
     project name: actionScript


>>>>> src/script.as

private function testMsg():void {
    mx.controls.Alert.show('ActionScript File안에 있는 함수 호출');
}





>>>>> src/script.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="vertical"  width="451" height="363">
    <!-- 외부에 정의된 ActionScript 파일을 로딩합니다.-->
    <mx:Style> <!-- CSS 적용 -->
        .alertTitle {
            fontSize: 18;

        }
        .alertMessage {
            fontSize: 18;
        }
        
        Alert {
            title-style-name: "alertTitle";
            message-style-name: "alertMessage";
        }
    </mx:Style>    
    <mx:Script source="./script.as" /> 
    <mx:Script>
        <![CDATA[
        private function showMsg():void {
            mx.controls.Alert.show('함수 호출');
        }


        private var gStr:String = "a"; // global 변수
        private function variable():void {
            var lStr:String ="b"; // local변수
            lStr = "c";
            txaMessage.text = "결과는" + gStr + lStr;// 결과는 ac 
        }
        ]]>
    </mx:Script>
    
    <mx:TextArea x="10" y="10" width="360" height="124" id="txaMessage" fontSize="18"/>
    <mx:Button label="show 함수 직접 호출" 
        click="mx.controls.Alert.show('MXML에서의 click 이벤트에서 직접 AcriptScript 호출')" fontSize="18"/>
    
    <mx:Button label="showMsg 함수 호출" click="showMsg()" fontSize="18"/>
    <mx:Button label="AS 파일안의 testMsg 함수 호출" click="testMsg()" fontSize="18"/>
    <mx:Button label="변수의 영역" click="variable()" fontSize="18"/>   
</mx:Application>



    
Posted by ▶파이팅◀

블로그 이미지
Let's start carefully from the beginning
▶파이팅◀

태그목록

공지사항

Yesterday
Today
Total

달력

 « |  » 2024.4
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

최근에 올라온 글

최근에 달린 댓글

글 보관함