0
votes

I have this problem :

TypeError: Error #2007: Parameter type must be non-null. at flash.events::EventDispatcher/addEventListener() at Ch05_02()

when I am running my flash doc the Ch05_02 as file

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();
      }
   }
}
1
Come on put some efforts! At least start debugger and check the line with the error....Andrey Popov
@AndreyPopov lines 13/14/15/16 (addEventListener)user3612646
Well this means that your _sfs is null, which is strange. Just play along with the debugger and check WHICH one is null and you will find the answer. Simply point over to the variable..Andrey Popov

1 Answers

0
votes

Looking at the documentation for SmartFox, it appears that you have the event names wrong. That's why the compiler is complaining about the type parameter being null. SFSEvent.CONNECTION, SFSEvent.ROOM_JOIN, et al do not exist and are therefore null.

You'll want to use the correct event names. SFSEvent.onConnection, SFSEvent.onJoinRoom, etc.