Transformation
The effect is as follows:
var str= "AZ";
for (Var i=0;i<str.length;i++) trace (Str.charcodeat (i));
Charcode:0-9: (48-57); A-Z: (65-90); A-Z: (97-122);
Converts the 10 binary number n to the D number (in 0-9,a-z,a-z characters) and D to 2-62
function Jh_10tod (N, D) {
n = math.floor (number (n));
D = Math.floor (number (d));
D = d<2? 2:d>62? 62:d;
var s, e = "";
while (n>0) {
s = n%d;
if (s>35) {
The number 36 to 62 is represented by a-Z character (s-36+97)
s = String.fromCharCode (s+61);
else if (s>9) {
The number 10 to 35 is represented by A-Z character (s-10+65)
s = String.fromCharCode (s+55);
}
e = s+e;
N = Math.floor (n/d);
}
E = e!= ""? E: "0";
return e;
}
Converts a D-number into a 10-system
function Jh_dto10 (str, d) {
D = Math.floor (number (d));
D = d<2? 2:d>62? 62:d;
var code = 0, num = 0;
for (var i = 0; i<str.length; i++) {
Code = str.charcodeat (i);
if (code>96) {
Code = 61;
else if (code>64) {
Code = 55;
} else {
Code = 48;
}
num + + code*math.pow (d, Str.length-1-i);
}
return num;
}
Test:
In_d = 62;
NUM1 = "15000";
num2 = Jh_10tod (NUM1, In_d);
Bt1.onrelease = function () {
num2 = Jh_10tod (NUM1, In_d);
};
Bt2.onrelease = function () {
NUM1 = Jh_dto10 (num2, In_d);
};