Use For in loop to display all properties in an object : For : Statement Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Statement » For »

 

Use For in loop to display all properties in an object


 
for (var element:String in targetObject) {
   // do some action
}

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var weather:Object = new Object();
        weather.temp = 45;
        weather.conditions = "rain";
        weather.pressure = 970;
        
        for (var element:String in weather) {
           trace(element + ": " + weather[element]);
        }

    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Statement
» For