SDK・ランタイムダウンロード
Flex SDKは入っているという前提で
http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_apollo
から、SDK、ランタイム、ドキュメントをそれぞれダウンロード。Flex Builder用の何かもあるけどどうせ使えないので無視。
ダウンロードしたら、ランタイムはインストール。SDK、ドキュメントは、Flex SDKのフォルダに上書きする。binの中にmxmlc.exeとamxmlc.batが入っているような構成になっていればいい。
プロジェクトの作成
とりあえず「test」というフォルダを作る。中には「test.as」というファイルを作る。
この中身はとりあえず
package { import flash.display.Sprite; import flash.system.Shell; import flash.events.InvokeEvent; import flash.ui.*; public class test extends Sprite { public function test() { Shell.shell.autoExit = true; Shell.shell.addEventListener(InvokeEvent.INVOKE, onInvoke); } private function onInvoke(e:InvokeEvent):void { new testWindow(); // ウィンドウ作成 stage.window.close(); } } } import flash.display.*; import flash.text.*; import flash.display.NativeWindow; import flash.events.MouseEvent; class testWindow extends NativeWindow { public function testWindow(width:uint = 320, height:uint = 240) { var winArgs:NativeWindowInitOptions = new NativeWindowInitOptions(); // winArgs.systemChrome = NativeWindowSystemChrome.NONE; // NONEにすると枠なしウィンドウになります winArgs.systemChrome = NativeWindowSystemChrome.STANDARD; winArgs.transparent = false; super(false, winArgs); // ウィンドウ作成 stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; // 文字 var helloText:TextField = new TextField(); helloText.text = "Hello Apollo World!"; helloText.autoSize = TextFieldAutoSize.LEFT; helloText.selectable = false; stage.addChild(helloText); // NativeWindowはDisplayObjectではないのでstageにくっつける // クリックで終了 stage.addEventListener(MouseEvent.CLICK, function():void { close(); } ); // 表示 this.width = width; this.height = height; visible = true; } }
とする。普通のAS3のコードに見えるが、若干見知らぬクラスが混ざっている。
ついでにtest-config.xmlも作成
<flex-config> <output>test.swf</output> <default-size> <width>320</width> <height>240</height> </default-size> <default-background-color>0xFFFFFF</default-background-color> </flex-config>
としておく。
これでコンパイルするわけだけど、いつものmxmlcではなく、amxmlcを使う。
amxmlc test.as
みたいな感じ。
これでswfファイルが出来上がるが、これはこのままでは動かない。既にApollo専用になっている。これをApolloアプリ化する。
実行
「test-app.xml」という空のファイルを作る。中身は
<?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://ns.adobe.com/apollo/application/1.0.M3" appId="cantrell.test" version="1.0"> <properties> <name>test</name> <description>test application.</description> <publisher>nazone</publisher> <copyright></copyright> </properties> <rootContent systemChrome="none" transparent="false" visible="false">test.swf</rootContent> </application>
こんな感じ。
出来上がったら、
adl test-app.xml
とする。adlはいわゆるデバッガだ。これで文字だけが表示される簡易アプリケーションの完成となる。
配布用airファイル作成
adt -package test.air test-app.xml .
で出来上がる。