Iterate through room properties
-
- Posts: 57
- Joined: 26 Oct 2010, 14:03
- Location: South Pasadena California
- Contact:
Iterate through room properties
Hey everyone, I am using Smartfox 1.x with Actionscript and I am wondering how to go about iterating through all the room properties I have set up. I can see the size of the properties array by using Room.properties.size(), but as far as iterating through these values I don't know the correct syntax. Could someone point me in the right direction?
Re: Iterate through room properties
Hello.
As the properties property is a HashMap, you can do it like you do in Java, by using the Iterator. It will stay something like:
As the properties property is a HashMap, you can do it like you do in Java, by using the Iterator. It will stay something like:
Code: Select all
var iterator = room.properties.entrySet().iterator();
while(iterator.hasNext()){
var obj = iterator.next();
trace("key: "+obj.getKey()+", value: "+obj.getValue());
iterator.remove();//// avoids a ConcurrentModificationException
}
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
-
- Posts: 57
- Joined: 26 Oct 2010, 14:03
- Location: South Pasadena California
- Contact:
Re: Iterate through room properties
Interesting, well thank you for the code example rjgtav. I have since reworked my code, so instead of individual properties for say "enemyLocationA", "enemyLocationB", etc, I just have an "enemyLocations" array property. Then I just get that property and iterate through it. Seems easier and cleaner. Thank you for the code example though, I might still need to use this. cheers!
Return to “Server Side Extension Development”
Who is online
Users browsing this forum: No registered users and 57 guests