vendredi 27 janvier 2017

How to remove word "null" from string in ActionScripts3

I have code for convert each 2 numbers to a specific character, this code works, but output is with an unwanted word "null". I want to remove it. I can't identify which part of code is wrong.

var encoded_numbers:String = "102030";
var sub:String;
var decode_string:String;

for (var i2:int = 0; i2 < encoded_numbers.length; i2 += 2) 
{
    sub = encoded_numbers.charAt(i2) + encoded_numbers.charAt(i2 + 1);
    //trace(sub);

    switch(sub) 
   { 
    case "10": 
        decode_string += "A";
        break; 
    case "20": 
        decode_string += "B";
        break; 
    case "30": 
        decode_string += "C";
        break; 

   }

}
trace(decode_string);//convert      

Output string:

nullABC

Aucun commentaire:

Enregistrer un commentaire