JSplash swf to javascript converter(2008/9/30)
- 2. 最近のブラウザは爆速らしい
Google V8 benchmark (Score)
700
600
500
400
300
200
100
0
IE7 Chrome Fx3.1 Safari
http://japan.cnet.com/blog/kichi/2008/09/23/entry_27014819/
- 4. 目標
Flashのゲームを
どうにかして
Javascriptで動かす
- 5. 手順
どうにかして読み込む
どうにかして描画する
どうにかしてASを動かす
- 6. 読み込み
swfmill というのがあります
http://swfmill.org/
swfバイナリ
<?xml version=quot;1.0quot;?>
<swf version=quot;7quot; compressed=quot;1quot;>
<Header framerate=quot;30quot; frames=quot;18quot;>
XML <size>
<Rectangle left=quot;0quot; right=quot;14000quot; top=quot;0quot; bottom=quot;8000quot;/>
</size>
<tags>
<SetBackgroundColor>
- 7. 読み込み
JS
重! JSplash.load_swf( {
header: {frameRate: 40, frames: 18, width:
14000, height: 8000},
taglist: [
{tag:JSplash.tSetBackgroundColor, rgb:'dd
dddd'} /*- 0 -*/,
{tag:null},
{tag:null},
{tag:JSplash.tDoAction},
軽い+パース不要
- 9. ActionScript
AVMを実装する? 考えたくもない
ASってそもそもECMAScriptなんだから
ブラウザに投げりゃよくね?
- 10. ActionScript
flare というのがあります
http://www.nowrap.de/flare.html
swfバイナリ
frame 1 {
stopAllSounds();
ソースコード delete onMouseDown;
var init;
this.play();
if (init == undefined) {
- 13. ActionScript
傾向と対策
thisは? → prototype.js の bind (解決)
グローバルは? → windowに突っ込んでおく(ちょっと苦しい)
_x とか _parent とかは? → スクリプト実行前後に設定、
チェックする(ちょっと苦しい)
- 14. ActionScript
ローカル変数は?
Frame 1 Frame 2 Frame 3
var a = 5; trace(++a); trace(++a);
6 7
- 15. ActionScript
実行時にスクリプトを書き換え
function() { function() {
var a = 5; var a = this.__locals__[‘a’];
} var a = 5; 保存
this.__locals__[‘a’] = a;
}
toString eval
function() { function() {
trace(++a); var a = this.__locals__[‘a’];
} trace(++a); 復帰
this.__locals__[‘a’] = a;
}
※ 子ムービークリップの参照などもこの方法で突っ込む
- 16. ActionScript
ローカル変数のリストは? → 手書き (苦しい)
その他(クロージャとか) → 全自動はきつい!
ASとの息詰まる闘い。
- 18. To Do
DefineButton
ビットマップデータ
音(できれば)
- 19. 本日コミット
よろしくお願いします
http://www.libspark.org/svn/ruby/jsplash/
20%