SimpleConnect的Logout和AVPresence的Bug | (29-01-2004) |
FlashcomGuru.com中有一篇文章教授如何為SimpleConnect加入真正的Logout功能。Macromedia的Components以Bug多著名,Flashcom組件根本沒有考慮過Logout情況,用戶要Logout,大不了關掉Browser。所以根據上述文章加入Logout功能,當用戶再Login時,AVPresence組件就會出問題。 如果你的應用程序同時用了幾個AVPresence,在Logout前,正在Publish影片,當Logout後再Login,然後用AVPresence去Publish影片,程序中所有AVPresence的Username會立即變成新登入名稱,其他連線中用戶的所有AVPresence都不能幸免。 我深入研究了AVPresence的Code,發現AVPresence設定了一個Global Variable叫broadcasting,當Publish影片時,它等於true;stopPublish時,它等於false。可是在AVPresence的close方法中,沒有將它改回false。 每次通過SimpleConnect連線成功後,SimpleConnect都會Call它旗下所有Component的setUsername方法,在AVPresence的setUsername方法中,有一段Code(第117-119行): if (_global.broadcasting && this.so.data.speakerID == this.userID) { this.so.send("changeUsername", this.username); } 結果當重新Login後,AVPresence的setUsername方法被Call,而broadcasting等於true,它以為自己正在Publish影片,立即用so.send通知所有連線中用戶的所有AVPresence,執行Shared Object中changeUsername方法(第75-77行): this.so.changeUsername = function (newName) { this.owner.username_txt.text = newName; }; 結果所有連線中用戶的所有AVPresence的username都變成了該新用戶的username。 [AVPresence的Bug示範檔案] (解壓到applications\avpresence_bug) 解決方法 當然是在AVPresence的close方法中加上: _global.broadcasting = false; |
|
本文章由發表。 |
意見 | |
沒有意見。 |
|
同組文章 |