Opensource Flex api / Actionscript api
Posted by vipuljhawar on August 10, 2007
List of some additional functions i have written for the flex project. Will keep on updating my api, regularly with reusable functions.
/** Determines if a string is upper case */ public function isUpperCase(value : String) : Boolean {
return isValidCode(value, 65, 90);
}
/** Determines if a string is lower case */
public function isLowerCase(value : String) : Boolean {
return isValidCode(value, 97, 122);
}
/** Determines if a string is digit */
private function isDigit(value : String) : Boolean {
return isValidCode(value, 48, 57);
}
/** Determines if a string is letter */
public function isLetter(value : String) : Boolean {
return (isLowerCase(value) || isUpperCase(value));
}
/** The meat of the functions which checks the values */
private function isValidCode(value : String, minCode : Number, maxCode : Number) : Boolean {
if ((value == null) || (StringUtil.trim(value).length < 1))
return false;
for (var i : int=value.length-1;i >= 0; i--) {
var code : Number = value.charCodeAt(i);
if ((code < minCode) || (code > maxCode))
return false;
}
return true;
}




