Wednesday, May 23, 2012

[Action Script] Cannot access a property or method of a null object reference. May,2012

So I'm making an mmo game and I cannot figure this out.

Code: protected function updateUserList ():void {
                        userlist.text = "";
                        for each (var client:IClient in chatRoom.getOccupants()) {
                                userlist.appendText(parseUsername(getUserName(client)));
                        }
                }

protected function chatMessageListener(fromClient:IClient, messageText:String):void{                       
msg.displayChatMessage(parseUsername(getUserName(fromClient)), Rank.USER, messageText);
                       
                }

protected function parseUsername(parseName:String):String               
                {
                        parseName = parseName.replace("[USER_ACCOUNT userid: ", "");
                        parseName = parseName.replace(",", "");
                        var parse:Array = parseName.split(" ");
                        parseName = parse[0];
                        return parseName;
                }TypeError: Error #1009: Cannot access a property or method of a null object reference.
at pages::lobbyP/parseUsername()
at pages::lobbyP/chatMessageListener()

The null object references appear in the chat message listener and user list listener.

Thanks for the help.
Cannot access a property or method of a null object reference.

Related Post



0 comments: