Get the length of an Object

Sometimes when working with Objects in AS3 you will want to loop through as you would an array using the length property. You can use the following function to return the length of the object:

//gets the length of an object

public static function getLength(o:Object):uint

{

var length:uint = 0;

for (var s:* in o)

length++;

return length;

}

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditShare on StumbleUponShare on TumblrEmail this to someone

Leave a Reply

Your email address will not be published.