웹사이트에서 어도비 에어 런타임을 설치하는 예제 Flex / Air

어도비 에어 런타임의 설치가 어떻게 이루어지는지 간단히 맛만 보기로 하자.

1. Flex Project를 생성한다. 여기서는 Flash Builder 4 Beta 2를 사용했다.

적절한 프로젝트 이름을 주고 플래시 플레이어를 이용하는 웹 프로젝트를 생성한다.

2. 메인 MXML(여기서는 TestAirInstaller.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/halo"
               minWidth="1024" minHeight="768"
               creationComplete="creationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            protected function creationCompleteHandler(event:FlexEvent):void
            {
                var airSWF:Object; // This is the reference to the main class of air.swf
                var airSWFLoader:Loader = new Loader(); // Used to load the SWF
                var loaderContext:LoaderContext = new LoaderContext();
                // Used to set the application domain
               
                loaderContext.applicationDomain = ApplicationDomain.currentDomain;
               
                airSWFLoader.contentLoaderInfo.addEventListener(Event.INIT, function(e:Event):void
                {
                    airSWF = e.target.content;
                    if(airSWF.getStatus() == "available"){
                        airSWF.installApplication(null, "");
                    }
                });
                airSWFLoader.load(new URLRequest("http://airdownload.adobe.com/air/browserapi/air.swf"),
                    loaderContext);
            }

        ]]>
    </fx:Script>
</s:Application>

3. 이제 이 프로그램을 실행한다. 인스톨러가 나타나는 것을 볼 수 있다.

일반적으로 Air를 이용하는 사이트들을 보면, 레이어 팝업을 띄운 뒤 팝업 내에서 에어 설치 프로그램을 구동하는 방식을 쓰는 듯 하다.

네이버 N드라이브의 설치 화면

소리바다의 설치 화면.

보다 상세한 내용을 알고 싶으면 Installing and running AIR applications from a web page 를 참고할 것.

Tag :

Leave Comments