Return to Snippet

Revision: 20295
at November 11, 2009 14:53 by BoNzO


Initial Code
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;

}

Initial URL

                                

Initial Description

                                

Initial Title
As3 verifaricare se una variabile è empty

Initial Tags

                                

Initial Language
ActionScript 3