物业ActionScript对象数量 [英] Actionscript object number of properties

查看:106
本文介绍了物业ActionScript对象数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能获得的属性在通用ActionScript对象是多少? (像数组长度)

How can I get the number of properties in a generic Actionscript Object? (Like Array length)

推荐答案

您必须遍历所有元素算来:

You will have to loop over all element to count them:

function objectLength(myObject:Object):int {
 var cnt:int=0;

 for (var s:String in myObject) cnt++;

 return cnt;
}

var o:Object={foo:"hello", bar:"world"};
trace(objectLength(o)); // output 2

这篇关于物业ActionScript对象数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆