Tag/AIR
「AIRで付箋紙アプリケーションを作ろう!」をやったよ。
[Think IT] 第1回:付箋紙アプリケーションを作ろう! をやってみたよ。 バックエンドは Django とか Pylons でやった訳ですが。
「これ、このままじゃ動かないんじゃ?」なところを調べながら作ってみて、 一応一通り動くところまで作った(つもり)。 恥をさらす為にも、書いたソース(抜粋)載せておこう。
以下、 menu.mxml 。
<mx:Script>
<![CDATA[
public var stickies:Array = new Array();
public function create():void
{
var sticky:Sticky = new Sticky();
sticky.show();
stickies.push(sticky);
}//END: create.
public function load():void
{
// re initialize stickies.
for (var i:int = 0; i < stickies.length; i++)
{
stickies[i].window.close();
delete stickies[i];
}
var request:URLRequest = new URLRequest("http://localhost:5000/stickies.xml");
request.method = 'GET';
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, function (evt:Event):void
{
var items:XMLList = (new XML(evt.target.data)).items.child('item');
if (items.length() > 0)
{
for each (var item:XML in items)
{
var sticky:Sticky = new Sticky();
sticky.id = item.id;
sticky.editor.text = item.body;
sticky.window.x = item.x * Capabilities.screenResolutionX;
sticky.window.y = item.y * Capabilities.screenResolutionY;
sticky.window.width = item.width;
sticky.window.height = item.height;
sticky.show();
stickies.push(sticky);
}
}
});
loader.load(request);
}//END: load.
public function save():void
{
for each (var sticky:Sticky in stickies)
{
var request:URLRequest;
if (sticky.id > 0)
{
request = new URLRequest('http://localhost:5000/stickies/'+sticky.id);
if (sticky.editor.text.length > 0)
{
request.method = 'PUT';
}
else
{
request.method = 'DELETE';
}
}
else
{
if (sticky.editor.text.length > 0)
{
request = new URLRequest('http://localhost:5000/stickies');
request.method = 'POST';
}
else
{
continue;
}
}
var variables:URLVariables = new URLVariables();
variables.x = sticky.window.x / Capabilities.screenResolutionX;
variables.y = sticky.window.y / Capabilities.screenResolutionY;
variables.width = sticky.window.width;
variables.height = sticky.window.height;
variables.body = sticky.editor.text;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.load(request);
}
}//END: save.
]]>
</mx:Script>
本編は [Think IT] 第1回:付箋紙アプリケーションを作ろう! でお楽しみください。
まだまだ日本語が化けまくりですが、 Adobe AIR は面白い!
ps. Pygments のActionScriptハイライトは0.9からなのかぁ。残念。
- Posted at:
- 2007/09/30 20:58:52
- 2 Comments
- 0 TrackBacks
- Tags:
- ActionScript
- AIR
- Flash
- Trackback:
- http://humming.via-kitchen.com/2007/09/30/tried-make-stickies-on-adobe-air/trackback/
Adobe AIRを触ってみたよ。
Adobe AIR を触ってみたよ。 インストーラを作るところまで調べたので、忘れないように自分用メモ。
何はともあれ Adobe Labs - Homepage からAIRのインストーラを落として来てインストール。
次に、開発に必要な Flex 3 SDK を Adobe Labs - Flex 3 Software Development Kit から落としてしてくる。 展開すると必要なものが一式入っているものの、インストーラは入ってないらしい。 ので、展開したものをそのまま使う。
今回は /usr/local の下に移動して、 PATH を通した。
$ unzip flex3sdk_b1_061107.zip
$ mv flex3sdk_b1_061107 /usr/local/flex3sdk
$ PATH="/usr/local/flex3sdk/bin:${PATH}"
whichとかしてみて、 PATH が通っているか確認。
$ which adl
/usr/local/flex3sdk/bin/adl
好きなディレクトリに移動して、テスト用のファイルを作って行く。 とりあえずhello worldを表示するだけのものを作る事に。
まずはHelloWorld-app.xmlを作る。
<?xml version="1.0" encoding="UTF-8"?>
<application
xmlns="http://ns.adobe.com/air/application/1.0.M4"
appId="com.gmail.mode.0renge.HelloWorld"
version="1.0"
>
<name>HelloWorld</name>
<description>Show only Hello World!.</description>
<rootContent
systemChrome="standard"
>HelloWorld.swf</rootContent>
</application>
次にHelloWorld.as。
package
{
import flash.display.*;
import flash.text.*;
public class HelloWorld extends Sprite
{
public function HelloWorld()
{
var txt:TextField = new TextField();
txt.autoSize = TextFieldAutoSize.LEFT;
txt.text = "Hello World!";
addChild(txt);
}
}
}
HelloWorld.asを amxmlc を使ってコンパイル。
$ amxmlc HelloWorld.as
Loading configuration file /usr/local/flex3sdk/frameworks/air-config.xml
This beta will expire on Wed Oct 31 00:00:00 JST 2007.
/path/to/current/HelloWorld.swf (649 bytes)
adl を使ってプレビューしてみる。
$ adl HelloWorld-app.xml
ちゃんと表示されれば一通り上手くいってる。(と思う。) ので、インストーラを adt を使って作成する。
$ adt -package HelloWorld.air HelloWorld-app.xml HelloWorld.swf
出来上がったHelloWorld.airでインストールしてみて、 ちゃんと表示されれば上手くいってるハズ。 コンパイルする時にエラーがあれば教えてくれるので、 特に迷うところは無いと思う。
FlashとかActionScriptとか、もっと覚えないとなぁ。
- Posted at:
- 2007/09/29 17:25:28
- 0 Comments
- 0 TrackBacks
- Tags:
- ActionScript
- AIR
- Flash
- Trackback:
- http://humming.via-kitchen.com/2007/09/29/adobe-air-memo/trackback/