更新的代碼讓我更接近。增量有些問題,但我不能把手指放在上面。如何將此代碼轉換爲函數? (Array to TextFields)
var myMovies:Array = ["Source Code", "Alice in Wonderland", "Zootopia", "Shrek", "Harry Potter"];
var inc:Number = 500; // starting vertical position
var increment:Number = 0;
function addField() {
var textBox:TextField = new TextField(); // assigns a variable to create a new text field
addChild(textBox); // adds the text field to the document
textBox.x = 150; // formats horizontal positioning
textBox.y = inc; // formats vertical positioning
inc-= 100; // subtracts 100px from vertical positioning
textBox.text = myMovies[increment];
increment++;// inserts array string into text box // goes to and stops on frame 2
}
if (increment < 5) {
addField();
} else {
gotoAndPlay(3);
}
你用什麼來佈置你的文本字段?聽起來像是一個定位問題? – Michael
你說得對 - 我修改了上面的代碼以包含位置格式。 :)任何提示都表示讚賞。計數器出現錯誤,導致代碼無法按建議工作。 – Lexii