Thanks for pointing this out.
The problem is in the documentation where it is not clearly explained that the values used in the properties array should be always strings.
To be more precise there can be 2 ways of working with this object: a basic way and an advanced one.
1) BASIC: just save any property you need in string form and retrieve it according to your needs.
This is the most simple way to attach any number of attributes to your User or Room objects. You can also store numbers in there, just remember to cast them back to their type before using them. Like this:
var n = Number ( usrObj.properties.get("n") )
2) ADVANCED: if you better understand the properties object you can use it for more interesting tasks.
The properties obj is java.util.HashMap object >>
http://java.sun.com/j2se/1.4.2/docs/api ... shMap.html
For example you can store entire nested objects in your properties, game attributes and so on.
Also you can use all the other usefull methods of the HashMap like
size(),
containsKey(),
containsValue() etc...
One last note:
The items inside a HashMap are up-casted to the java.lang.Object type, that's why you should need to cast the values you get back from the map to their original type.
One nice workaround to avoid this casting operation is to wrap all your properties inside an Actionscript object.
Code example:
Code: Select all
var o = {}
o.name = "this is my name" // string
o.age = 20 // number
o.married = false // boolean
usrObj.properties.put("myData", o)
This way all the variables wrapped in the "o" object will have their type preserved and there's no need to cast them
Quite a long explanation
We're in the process of releasing a new update with many new little fixes and features. We'll surely add these infos in the docs as well.
Hope it helps!
