Luar's Flash Playground:SimpleConnect的Logout和AVPresence的Bug
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;
本文章由發表。
意見
"; print "沒有意見。
 "; } ?>
  • i choose to stopPublish and stopReceive 1 second before logOut.
    and i added following two lines in sopReceive func:
    this.level.mask._height = 1;
    this.username_txt.text="(open)";
    and also added
    _global.broadcasting = false;
    in close func.

    did u ever experience such a problem:
    after i reconnected and i click
    on a AV box (trying to startPublish) which was receiving
    video before i stopReceive (of course before i reconnect). i can see only "Video off". but the sound work fine. and other people in the same room can recive my video too!

    But if i click on the AV box i was publish before or any AV box which no one used before... it works fine.

    由poker於02-03-2004發表

  • 我不是免費技術支援

    luar於02-03-2004發表

  • it's just a discussion, not a kind of commercial deal. i am learning myself and just want to discuss that with u ..and of course make friends..if that doesn't trouble u much. :(
    my email is palax@163.com

    由poker於02-03-2004發表

  • and i don't have your email & QQ , also i am not the kind of person who alway want to get help from other without doing anything himself.

    由poker於02-03-2004發表

  • 請問用戶關閉瀏覽器會執行那個simpleConnectd事件呢?

    liu21st於03-06-2004發表

  • yes

    luar於03-06-2004發表

同組文章