I'm having more issues with avatars. I am using the following code:
Code: Select all
function onJoin(evt:SFSEvent):void
{
trace("Room joined successfully");
if (! sfs.mySelf.containsVariable(this.USERVAR_X) && ! sfs.mySelf.containsVariable(this.USERVAR_Y))
{
var px:int = Math.round(Math.random() * this.Town.width);
var py:int = Math.round(Math.random() * this.Town.height);
var dir:String = this.AVATAR_DIRECTIONS[2];
setAvatarVariables(px, py, dir);
}
function setAvatarVariables(px:int, py:int, dir:String):void
{
var userVars:Array = [];
userVars.push(new SFSUserVariable(this.USERVAR_X, px));
userVars.push(new SFSUserVariable(this.USERVAR_Y, py));
userVars.push(new SFSUserVariable(this.USERVAR_DIR, dir));
sfs.send(new SetUserVariablesRequest(userVars));
}
function onUserVarsUpdate(evt:SFSEvent):void
{
var changedVars:Array = evt.params.changedVars as Array;
var user;
this.User = evt.params.user as this.User;
// Check if the user changed his position
if (changedVars.indexOf(this.USERVAR_X) != -1 || changedVars.indexOf(this.USERVAR_Y) != -1)
{
// Check if avatar exists
if (this.getAvatar(user.id) != null)
{
// Move the user avatar
this.moveAvatar(user);
}
else
{
// Create the user avatar
this.createAvatar(user, true);
}
}
}
}
private function onJoinError(evt:SFSEvent):void
{
trace("Room joining failed");
}
Which comes up in the output log with all of this:
Code: Select all
TypeError: Error #2007: Parameter value must be non-null.
at flash.utils::ByteArray/writeUTF()
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/binEncode_UTF_STRING()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:716]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/encodeObject()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:355]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/arr2bin()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:98]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/array2binary()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:88]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/encodeObject()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:391]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/arr2bin()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:98]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/array2binary()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:88]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/encodeObject()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:391]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/obj2bin()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:72]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/object2binary()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:56]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/encodeObject()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:395]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/obj2bin()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:72]
at com.smartfoxserver.v2.protocol.serialization::DefaultSFSDataSerializer/object2binary()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/protocol/serialization/DefaultSFSDataSerializer.as:56]
at com.smartfoxserver.v2.entities.data::SFSObject/toBinary()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/entities/data/SFSObject.as:150]
at com.smartfoxserver.v2.core::SFSIOHandler/onDataWrite()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/core/SFSIOHandler.as:285]
at com.smartfoxserver.v2.core::SFSProtocolCodec/onPacketWrite()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/core/SFSProtocolCodec.as:73]
at com.smartfoxserver.v2.bitswarm::BitSwarmClient/send()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/bitswarm/BitSwarmClient.as:266]
at com.smartfoxserver.v2::SmartFox/send()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/SmartFox.as:1770]
at Function/Main/onJoin/setAvatarVariables()[C:\Users\Zach Harland\Desktop\SPSrc\src\Main.as:99]
at Main/onJoin()[C:\Users\Zach Harland\Desktop\SPSrc\src\Main.as:89]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.smartfoxserver.v2.controllers::SystemController/fnJoinRoom()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/controllers/SystemController.as:289]
at com.smartfoxserver.v2.controllers::SystemController/handleMessage()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/controllers/SystemController.as:139]
at com.smartfoxserver.v2.core::SFSProtocolCodec/dispatchRequest()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/core/SFSProtocolCodec.as:150]
at com.smartfoxserver.v2.core::SFSProtocolCodec/onPacketRead()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/core/SFSProtocolCodec.as:54]
at com.smartfoxserver.v2.core::SFSIOHandler/handlePacketData()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/core/SFSIOHandler.as:252]
at com.smartfoxserver.v2.core::SFSIOHandler/onDataRead()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/core/SFSIOHandler.as:111]
at com.smartfoxserver.v2.bitswarm::BitSwarmClient/onSocketData()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer.2X/API/AS3/src/com/smartfoxserver/v2/bitswarm/BitSwarmClient.as:454]
(Note: I took out the other logged stuff, like the room being successfully joined and what not.)
Also, this happens when I initiate a successful login and room join!
Hope you can help, thanks!
![Smile :)](./images/smilies/icon_smile.gif)