开发者

How to adjust numToChar to support any key (AS3)

开发者 https://www.devze.com 2023-01-11 20:46 出处:网络
I have a flash conversion function that I call like this: var key:String=numToChar(keyboardEvent.charCode);

I have a flash conversion function that I call like this:

var key:String=numToChar(keyboardEvent.charCode);

currently the function (see below) supports limited US character set, how to enhance this function as much as possible easily without hardcoding? I want to make the function to support all standard western keycodes (available in US INTERNATIONAL KEYBOARD) such as $€!#%;;!üÜÅÄÖéÉíÍ

The function is:

        private function numToChar(num:int):String {
if (num > 47 开发者_高级运维&& num < 58) {
    var strNums:String = "0123456789";
    return strNums.charAt(num - 48);
} else if (num > 64 && num < 91) {
    var strCaps:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    return strCaps.charAt(num - 65);
} else if (num > 96 && num < 123) {
        var strLow:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    //var strLow:String = "abcdefghijklmnopqrstuvwxyz";
    return strLow.charAt(num - 97);
} else {
    return num.toString();
}


is this good one String.fromCharCode ?

0

精彩评论

暂无评论...
验证码 换一张
取 消