reading roomVariables problem
Posted: 18 Feb 2006, 13:51
Simple question first.
Can I access, from the client code, all the roomVariables from all the rooms in the zone I'm currently connected to (roomList)? If so, how?
I'm strugling with the roomVariables tutorial and I can't seem to find an answer.
I'm setting my variables directly from the server in the config.xml like
But it seems I'm dooing something wrong reading them. I can see the variables set with the admin tool.
I first tried like this
I've then added an onRoomVariablesUpdate event but it's not beeing called
Then in the roomVariables fla example it states "// variables = a property Object containing all room variables" - for the roomObject, as opposed from the documentation where we have getVariables() and getVariable() methods of the Room object.
One other question. It seems to me that the user that sets a room variable doesn't recieve the onRoomVariablesUpdate event. Is that correct? Or am I dooing something wrong?
Can you tell if I'm dooing someting wrong?
I'm building a lobby and I need to access other variables besides the names of one room and display them in the lobby. Is this possible or do i need to write a method for the lobby extension?
Can I access, from the client code, all the roomVariables from all the rooms in the zone I'm currently connected to (roomList)? If so, how?
I'm strugling with the roomVariables tutorial and I can't seem to find an answer.
I'm setting my variables directly from the server in the config.xml like
Code: Select all
<Room name="Room1" maxUsers="12" isPrivate="false" isTemp="false" uCountUpdate="true">
<Vars>
<Var name="initBet" type="n" private="true">500</Var>
<Var name="gameType" type="s" private="true">Challenge</Var>
</Vars>
</Room>
I first tried like this
Code: Select all
smartfox.onRoomListUpdate = function(roomList:Object){
this.autoJoin();
for (var r in roomList){
trace("Room: "+r+" > "+roomList[r].getName()); // traces corectly
vars = roomList[r].getVariables();
for (var v in vars) {
trace("Var "+v+"="+vars[v]); // traces nothing
}
// in fact it doesn't enters the for because the vars is an empty object as it turned out at the debugging
}
}
Then in the roomVariables fla example it states "// variables = a property Object containing all room variables" - for the roomObject, as opposed from the documentation where we have getVariables() and getVariable() methods of the Room object.
One other question. It seems to me that the user that sets a room variable doesn't recieve the onRoomVariablesUpdate event. Is that correct? Or am I dooing something wrong?
Can you tell if I'm dooing someting wrong?
I'm building a lobby and I need to access other variables besides the names of one room and display them in the lobby. Is this possible or do i need to write a method for the lobby extension?