0

我有这个问题:

TypeError:错误 #2007:参数类型必须为非空。在 Flash.events::EventDispatcher/addEventListener() 在 Ch05_02()

当我运行我的闪存文档时,Ch05_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 Ch05_02 extends MovieClip{
      private var _sfs:SmartFoxClient;
      private var _avatarList:Array = new Array();

      public function Ch05_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","");
         }
      }

      private function onRoomListUpdate(e:SFSEvent):void
      {
         _sfs.autoJoin();
      }
   }
}
4

1 回答 1

0

查看 SmartFox的文档,您似乎有错误的事件名称。这就是为什么编译器抱怨type参数是null. SFSEvent.CONNECTION, SFSEvent.ROOM_JOIN, 等不存在,因此存在null

您需要使用正确的事件名称。SFSEvent.onConnection,SFSEvent.onJoinRoom等。

于 2014-05-07T19:18:11.707 回答