2012年5月24日 星期四

how to pass JSON thru flashvars?

如何透過 flashvars 傳遞 JSON 字串?

[in html]
var flashvars = {
  conf_txt: '{ "x":"100", "y":"50", "txt":"this is test" }'
}

[in flash]
var o:Object = JSON.decode(this.loaderInfo.parameters.conf_txt))
trace(o.x, o.y, o.txt);// 100, 50, this is test

but...如果有中文字的話...就會爆炸...

2012年5月23日 星期三

how to tag and link name in a facebook message using flash(as3)

此方法已失效

facebook 訊息中標記人名(@人名)
常用 twitter 的朋友應該知道 @someone 這種寫法,
facebook 訊息也支援這種方式,
手動打 "@someone" 在 facebook 裡會 work,
但程式如果照這種方式送,很抱歉不會鳥你。

正確的格式是
@[friendId :friendName]

how to tag people(friends) in a facebook photo using flash(as3)

facebook 上傳照片時如何 tag 朋友?

可以用 tags 這個這個屬性,
tags:JSON.encode([ { "tag_uid":_friendId, "x":0, "y":0 } ])

說明如下,
tag_uid: friend id
tag_text: some text
x: 水平x座標,百分比[0-100]
y: 垂直y座標,百分比[0-100]

*注意* 最後記得要 JSON.encode 成字串

完整範例如下

2012年5月11日 星期五

how to enable gzip on dotcloud

put nginx.conf at the root of application.
cat nginx.conf
gzip on;
gzip_http_version 1.0;
gzip_types text/plain application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript font/truetype;
gzip_disable "MSIE [1-6]\.";

now restart nginx.
dotcloud run app.www sudo /etc/init.d/nginx restart

enjoy it.

2012年4月30日 星期一

2012年4月24日 星期二

sublime text 2 tips

sublime text 2
一定要用它超好用的 multi-selection 功能

ctrl+alt+up/down:開啟 select lines 功能
alt+shift+方向鍵 or shift+方向鍵:select words
ctrl+mouse click:開啟 multi-selection 功能

游標在要選取的文字上,ctrl+d 逐一選取文件中相同的文字
游標在要選取的文字上,alt+F3 選取文件中所有相同的文字

其它常用的功能
ctrl+shift+p:command mode
ctrl+p:切換 folder 裡的檔案
alt+Number:切換分頁
ctrl+r:@goto symbol/definition
ctrl+alt+a:alignment

sublime text 2 build swf

sublime text 2 build swf

ctrl+shift+p
install package for actionscript3

tools->build system->new build system
{
"cmd": ["d:\\Data\\Data\\My documents\\ProgramFiles\\flex_sdk_4.5.1\\bin\\mxmlc.exe", "${file}"],
"selector": "source.actionscript",
"encoding": "big5"
}
save as ActionScript.sublime-build
c:\Users\XXX\AppData\Roaming\Sublime Text 2\Packages\ActionScript 3\

不設 encoding 會噴
Decode error - output not utf-8

ctrl+b or F7
compile as3