Posted By

feeorin on 02/22/11


Tagged

array length associative as3


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

merritt212


Get the length of an associative array


 / Published in: ActionScript 3
 

  1. /**
  2.  * Returns the length of an associative array or object similar function to Array.length
  3.  *
  4.  * @param $obj
  5.  * @return int
  6.  *
  7.  */
  8. public static function __getAssociativeArraySize($obj:Object):int {
  9. var length:int = 0; /* the length counter to be returned */
  10. if ($obj != {} || $obj != null) { /* check if the object is null or has no elements and return zero as the length */
  11. for (var s:String in $obj) { /* iterate on each element of the object and increase the counter */
  12. length++;
  13. }
  14. }
  15.  
  16. return length; /* return the length*/
  17. }

Report this snippet  

You need to login to post a comment.