0

你好我有这个问题ReferenceError:错误#1065:未定义变量onJoinRoom。在 Ch03_02() 当我运行我的 flash doc 时,Ch03_02 作为文件

    package {
import it.gotoandplay.smartfoxserver.SmartFoxClient;
import it.gotoandplay.smartfoxserver.SFSEvent;
import it.gotoandplay.smartfoxserver.SFSEvent.onJoinRoom;
import it.gotoandplay.smartfoxserver.data.Room;
import it.gotoandplay.smartfoxserver.data.User;
import flash.display.*;
public class Ch03_02 extends MovieClip{
private var _sfs:SmartFoxClient;
private var _avatarList:Array = new Array();
public function Ch03_02() {
_sfs = new SmartFoxClient(true);
_sfs.addEventListener(SFSEvent.onConnection,onConnection);
_sfs.addEventListener(SFSEvent.onRoomListUpdate,onRoomListUpdate);
_sfs.addEventListener(SFSEvent.onJoinRoom,onJoinRoom);
_sfs.addEventListener(SFSEvent.onUserEnterRoom,onUserEnterRoom);
_sfs.addEventListener(SFSEvent.onUserLeaveRoom,onUserLeaveRoom);
_sfs.connect("127.0.0.1",9339);
}
private function onConnection(e:SFSEvent):void
{
var ok:Boolean = e.params.success;
if (ok){
_sfs.login("simpleChat","myname","");
}
}
private function onRoomListUpdate(e:SFSEvent):void
{
_sfs.autoJoin();
}
}
}
4

1 回答 1

0

您的活动名称无效。SFSEvent 类中没有定义 onJoinRoom 事件类型试试这个:

    package {
    import it.gotoandplay.smartfoxserver.SmartFoxClient;
    import it.gotoandplay.smartfoxserver.SFSEvent;
    import it.gotoandplay.smartfoxserver.SFSEvent;
    import it.gotoandplay.smartfoxserver.data.Room;
    import it.gotoandplay.smartfoxserver.data.User;
    import flash.display.*;
    public class Ch03_02 extends MovieClip {
        private
        var _sfs: SmartFoxClient;
        private
        var _avatarList: Array = new Array();
        public

        function Ch03_02() {
            _sfs = new SmartFoxClient(true);
            _sfs.addEventListener(SFSEvent.CONNECTION, onConnection);
            _sfs.addEventListener(SFSEvent.ROOM_JOIN, onJoinRoom);
            _sfs.addEventListener(SFSEvent.USER_ENTER_ROOM, onUserEnterRoom);
            _sfs.addEventListener(SFSEvent.USER_EXIT_ROOM, onUserLeaveRoom);
            _sfs.connect("127.0.0.1", 9339);
        }
        private function onConnection(e: SFSEvent): void {
            var ok: Boolean = e.params.success;
            if (ok) {
                _sfs.login("simpleChat", "myname", "");
            }
        }
    }
}
于 2013-08-30T12:07:02.947 回答