When i retrieve the roomlist with getRooms and loop through the room array i can get the correct room ID.
Code: Select all
function getRoomIdByRoomName(danceID)
{
var tmproom = zone.getRoomByName(danceID);
trace("DanceID: " + danceID + " has roomID: " + tmproom.getId());
var roomList = zone.getRooms();
for(var i=0;i<roomList.length;i++)
{
if (roomList[i].getName() == (danceID + ""))
{
//return roomList[i].getId();
}
trace("ROOM: " + roomlist[i].getName() + " | " + roomlist[i].getId());
}
return -1;
}
Code: Select all
[mcZone.as]: DanceID: 19 has roomID: 3
[mcZone.as]: Room: dummyRoom | 2
[mcZone.as]: Room: holderRoom | 1
[mcZone.as]: Room: 18 | 3
[mcZone.as]: DanceID: 18 has roomID: 3
[mcZone.as]: Room: dummyRoom | 2
[mcZone.as]: Room: holderRoom | 1
[mcZone.as]: Room: 18 | 3
[mcZone.as]: DanceID: 12 has roomID: 3
[mcZone.as]: Room: dummyRoom | 2
[mcZone.as]: Room: holderRoom | 1
[mcZone.as]: Room: 18 | 3
What i am trying to do: There are 3 rooms defined. I am looking for the room with name 18, i want the room id of that room. (the above code is located within a function to do that). i give danceID 12, the code matches roomID 3 (??) i give danceID 19, the code matches roomID 3 (??) it should only match roomID 3 to danceID 18... why is this happening?