开发者

Problem with a property name of an object

开发者 https://www.devze.com 2023-01-30 14:06 出处:网络
I have this function: private function returnFees(row:Object,name:String):int { var fee:int; for each(var obj:Object in row)

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;   
                }

 开发者_如何学JAVA           }
            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


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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号