PHP base_convert() in AS3

Here is a quick example of how to use PHP’s base convert function in AS3. A lot of people use this function for shorter masked URLs like YouTube. Easy enough but took me a minute to find the equivalent in actionscript.

PHP:

function encode36($x){
    return base_convert($x, 10, 36);
}
function decode36($x){
    return base_convert($x, 36, 10);
}

Actionscript 3:

function encode36(x:Number):String{
    return x.toString(36);
}
function decode36(x:String):int {
    return parseInt(x,36);
}

, ,