MXML에 ActionScript를 정의하는 방법은 두 가지가 있다.

1. MXML안에 직접 정의하는 방법
in test.mxml
<mx:Script>
  <![CDATA[
       import mx.controls.Alert;

       function sayHello(){
           Alert.show("hi")
       }
  ]]>
</mx:Script>

2. 외부 파일에 정의하고 그 파일을 지정하는 방법
in test.mxml
<mx:Script source="as3/test.as">
</mx:Script>


in as3/test.as (
import mx.controls.Alert;

function sayHello(){
  Alert.show("hi")
}

2번처럼 mx:Script를 정의할 때 source를 넣어준 경우 inline에 actionscript를 넣을 수 없다.


'programming > flex2.0' 카테고리의 다른 글

Flex 2에서 control들의 data provider 설정 방법  (2) 2006.11.16

+ Recent posts