Created
August 7, 2012 08:22
-
-
Save RhinoLu/3283150 to your computer and use it in GitHub Desktop.
Gaia Framework 處理 light box
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* - 需求: | |
* 有個公告單元(bulletin),獨立於其他單元,在瀏覽其他單元時,可以隨時開啟或關閉 | |
* 但必須透過網址記錄行為 | |
* | |
* - 解法: | |
* 在原來的 branch 後面加上自定義字串, | |
* 之後再判斷 deeplink 裡是否有該字串。 | |
**/ | |
// assets.bulletin 是 light box swf | |
private function onBulletinClick(e:MouseEvent):void | |
{ | |
if (Gaia.api) { | |
var b:String = Gaia.api.getCurrentBranch(); | |
// 先判斷是否已開啟(isShow) | |
if (Gaia.api.getPage(Pages.NAV).assets.bulletin.content.isShow) { | |
// 已開啟,移除 /?xxx 後送出 | |
Gaia.api.goto(b); | |
}else { | |
// 未開啟,branch 後面加上 /?xxx 後送出 | |
Gaia.api.goto(b + "/?bulletin"); | |
} | |
} | |
} | |
// 其他 page 會觸發 onDeeplink 事件,再用 e.deeplink 判斷是否要開啟 light box | |
override public function onDeeplink(e:GaiaSWFAddressEvent):void | |
{ | |
super.onDeeplink(e); | |
trace(this, "onDeeplink", Gaia.api.getValue()); | |
trace(this, "onDeeplink", e.deeplink); | |
if (Gaia.api.getValue().indexOf("bulletin") > -1) { | |
showBulletin(); | |
}else { | |
hideBulletin(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment