1 Reply Latest reply on Nov 20, 2007 4:23 AM by levancho

    How to get Object key name

      var obj:Object = {a:"foo", b:"bar"}
      obj.a // foo keya=a value='foo'
      obj.b // bar keya=b value="bar"

      for each (var value:Object in obj){

      Q: How can I get key from obj liking hash?
        • 1. Re: How to get Object key name
          levancho Level 3
          var obj:Object = {a:"foo", b:"bar"}
          var retValue:String;
          for ( var key:* in obj)
          if ( obj[key] == "foo")
          retValue= key;
          return retValue;

          (you could of course return it straight from within the loop but thats not very good idea, so , you get the idea right?