avatarskin object instead of anonymous object

Post here your questions about the OpenSpace 1.x or notify bugs and suggestions.

Moderators: Lapo, Bax

Post Reply
Robhuhn
Posts: 4
Joined: 02 Sep 2008, 06:32

avatarskin object instead of anonymous object

Post by Robhuhn »

Hi all,

i am just on to replace the example skins with my own skins.
For this i created an AvatarSkin class containing a path(as string) to the skin image. This Object of AvatarSkin is tranfered by the method openSpaceEngine.

Code: Select all

openSpaceEngine.createMyAvatar("avatar", null, avatarModel.skin, ...
The event dispatched by openSpace is caught in my avatar class:

Code: Select all

public function onSkinChange(event : AvatarEvent) : void
{
       var skin : AvatarSkin = event["params"].skin;
}
So far so good :)
Now if i log in and noone else is in the room joined by me, the object in my event.params.skin is type of AvatarSkin. If i log in and another user joined the room before, my event.params.skin is type of Object.
The other user has the same sources like me.

Does openSpace do anything else with the transfered object but passing it through or does anybody have an idea how this could be?

Thanks in advance.
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

When you call the OpenSpace.setMyAvatarSkin method passing the skin object as a parameter, OpenSpace serializes this object using JSON before sending it to SmartFoxServer for broadcasting to the other clients.
Custom classes can't be serialized; you can only use primitive types, arrays and objects.
It only works for your own avatar because the object is passed directly to the avatar class.
Paolo Bax
The SmartFoxServer Team
danielfck
Posts: 12
Joined: 24 Sep 2009, 03:12
Contact:

Post by danielfck »

Guys,

i saw one of the example codes in the OpenSpace documentation on skinChange.

the code are as follows:

public function onSkinChange(evt:AvatarEvent):void
{
// Get skin object from event parameters
var skin:Object = evt["params"].skin

// Retrieve avatar sex and hat
var sex:String = skin.sex
var hat:String = skin.hat
...
}


Question: How can I know what are the properties in the skin itself, eg, like sex and hat?
How can I see more than just 2?

I don't see any of it in the documentation. Hope you can enligten me up.
Thanks
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

The skin object is a generic object, and you can assign any properties to it. Check the OpenSpace.setMyAvatarSkin method API reference.
Paolo Bax
The SmartFoxServer Team
danielfck
Posts: 12
Joined: 24 Sep 2009, 03:12
Contact:

Post by danielfck »

The skin object is a generic object, and you can assign any properties to it. Check the OpenSpace.setMyAvatarSkin method API reference.
dont have lah... :(
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

Sorry?
Paolo Bax
The SmartFoxServer Team
Post Reply