AS3修改从数组中读取文本而不是从xml读取

时间:2015-03-04 15:26:58

标签: xml actionscript-3 flash

请帮我修改AS3代码以从数组中读取文本,而不是从xml中读取文本。

原始代码:

function readTheText() {
// Zeroing the TEXT
// ------------------------------------------
DisplayHolder.MultiLetters_MC.TheText = "";
// clear the previous interval
clearInterval(PhraseChange);
// ------------------------------------------
// Reading the text from the XML
// ------------------------------------------
for (i=0; i < NumOfLines; i++) {
    this["textLine"+i] = myXml.firstChild.childNodes[LinesCount].childNodes[i].firstChild.nodeValue;
    if (this["textLine"+i] == undefined){
        this["textLine"+i] = " ";
    }
    padLength = NumOfLettersInLine - this["textLine"+i].length;
    // Add padding if necessary
    if (padLength > 0){
        for (p=0; p < padLength; p++) {
            this["textLine"+i] += " ";
        }
    } else {
        // Subtract letters if necessary
        var theString:String = this["textLine"+i];
        var theSubString:String = theString.substring(0,NumOfLettersInLine);
        this["textLine"+i] = theSubString;
    }
    // Our final text
    DisplayHolder.MultiLetters_MC.TheText += this["textLine"+i];
}...

将xml中的读取替换为:

&#13;
&#13;
    var group1:Array = ['DRIFT', 'FRESH&TONIC', 'SHIT ON GRASS', 'DOWNTOWN', 'AGED NEGRONI', 'FIREBALL', 'B5200', 'BLACK JACK', 'HOT WORM'];
var texts:Array = [];
&#13;
&#13;
&#13;

最好的问候

1 个答案:

答案 0 :(得分:1)

  1. NumOfLines替换为group1.length
  2. myXml.firstChild.childNodes[LinesCount].childNodes[i].firstChild.nodeValue;替换为group1[i];
相关问题