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.