/ Published in: ActionScript 3

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static function empty(variable:*) : Boolean { var isEmpty:Boolean; if (variable == null || variable == undefined) { isEmpty = true; } else if (variable is String) { var str:String = variable.replace(/^\s+|\s+$/g, ''); isEmpty = (str.replace(/\s+/g, ' ') == "" || variable == "" || variable == "0" || variable == "false"); } else if (variable is Number || variable is int || variable is uint) { isEmpty = (variable == 0); } else if (variable is Array) { isEmpty = (variable.length == 0); } else if (variable is Boolean) { isEmpty = (variable == false); } return isEmpty; }
Comments
