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

问题描述 投票:0回答:1

如何修改 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 中读取的内容替换为:

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

xml actionscript-3 flash
1个回答
1
投票
  1. NumOfLines
    替换为
    group1.length
  2. myXml.firstChild.childNodes[LinesCount].childNodes[i].firstChild.nodeValue;
    替换为
    group1[i];
© www.soinside.com 2019 - 2024. All rights reserved.