john
john

Reputation: 85

Problem with a property name of an object

I have this function:

private function returnFees(row:Object,name:String):int
        {
            var fee:int;
            for each(var obj:Object in row)
            {   

                if(obj==name)
                {
                    //fee=obj as int;   
                }

            }
            return fee;
        }

I want to compare the name of properties to the 'name'. But in this code the 'obj' is giving me the values of properties not the name.

Any ideas? thank you

Upvotes: 0

Views: 60

Answers (1)

Patrick
Patrick

Reputation: 15717

It's not a for each you have to use but a simple for. for each will give you the values and for the property name :

private function returnFees(row:Object,name:String):int {
 var fee:int;

 for (var rowName:String in row) {
  if(rowName == name) {
      //fee=obj as int;   
  }
 }
 return fee;
}

Upvotes: 2

Related Questions