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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With