1 Reply Latest reply on Apr 2, 2009 2:15 PM by kglad

    for in loop to show object members and then assigning them how? Help

    combustion007
      Hi guys,

      I have a question that involves for..in loop to capture what ever exist within an object. Let say I have an object:

      var s1:Object = { Id:'1', Name:'John Smith', Phone:'555-555-5555', Email:'john.smith@xxxx.com' };

      I use the for in loop to read the object members and their properties like this:

      for(var a in s1)
      {
      trace(s1[a]);
      }

      This for...in loop show all the information as expected. The question is what if I would like to assign variables to object members. I have tried this way but not doing the trick:

      for( var a in s1)
      {
      var id:Number = s1[a][0];
      var Name:String = s1[a][1];
      var Phone:Number = s1[a][2];
      }

      and so. Can you guys help point out what am I doing wrong, please.

      Thanks a bunch.