Posted By

feeorin on 02/22/11


Tagged

array elements remove parameters associative as3


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

merritt212


Remove elements from an associative array


 / Published in: ActionScript 3
 

  1. /**
  2.  *
  3.  * @param $obj The object you want to delete elements from
  4.  * @param parameters A comma delimeter parameters to be passed on the object for deletion, if a parameter is not found the object it will be skipped
  5.  * @return The new object with the deleted element
  6.  *
  7.  */
  8. public static function deleteElements ($obj:Object, ...parameters):Object {
  9.  
  10. if ($obj != {} || $obj != null) {
  11. for (var s:String in parameters) {
  12. if ($obj[parameters[s]] && $obj[parameters[s]] != undefined) {
  13. $obj[parameters[s]] = null;
  14. delete $obj[parameters[s]];
  15. } else {
  16. trace ("parameter,", parameters[s], "was skipped as it couldn't be found on the object");
  17. }
  18. }
  19. }
  20.  
  21. return $obj;
  22. }

Report this snippet  

You need to login to post a comment.