动作脚本3引号内的换行符

时间:2016-04-13 01:57:52

标签: actionscript-3

我对ActionScript语言相当新,我想知道如何在动态文本字段中添加换行符。

我将文本设置为通过数组显示在文本框中,但有些问题比其他问题长得多。这意味着部分或大部分文字都已脱离屏幕。

我正在寻找与html <br>标记相同的内容或效果。

感谢您的回答并感谢您的时间。 (这是框架的代码)

import flash.events.MouseEvent;

stop();

var nQNumber:Number = 0;
var aQuestions:Array = new Array();
var aCorrectAnswers:Array = new Array("c", "ab", "c", "c", "d", "b", "a", "b", "a", "a", "abceg", "a", "b", "a", "a")
var aUserAnswers:Array = new Array();
var cQAnswers:Array = new Array();

aQuestions[0] = "What does the evacuation siren sound like?";
aQuestions[1] = "What must you do if you hear the eacuation siren? (Multiple Answers)";
aQuestions[2] = "What must you do with cigarette lighters or matches while on the manifacturing site?";
aQuestions[3] = "Is it OK to carry a mobile phone on the manufacturing area of the site?";
aQuestions[4] = "What must you do if a chemical comes into contact with your eyes or skin?";
aQuestions[5] = "What is the maximum speed permitted on site?";
aQuestions[6] = "Who has the right of way at pedestrian crossings?";
aQuestions[7] = "Who must you report any injuries, incidents, near misses or hazards to?";
aQuestions[8] = "Where is the evacuation assembly area?";
aQuestions[9] = "Where can you access a Saftey Data Sheet? (Multiple Answers)";
aQuestions[10] = "What Personal Protective Equipment is required to be worn at all times on the manufacturing site? (Multiple Answers)";
aQuestions[11] = "Who is permitted to drive a forklift on site?";
aQuestions[12] = "When are you permitted to remove a tag?";
aQuestions[13] = "What is required before any maintenance or repairs are carried out on the plant? (Multiple answers)";
aQuestions[14] = "When should you wash your hands?";

cQAnswers[0] = "";
cQAnswers[1] = "";
cQAnswers[2] = "";
cQAnswers[3] = "";
cQAnswers[4] = "";
cQAnswers[5] = "";
cQAnswers[6] = "";
cQAnswers[7] = "";
cQAnswers[8] = "";
cQAnswers[9] = "";
cQAnswers[10] = "";
cQAnswers[11] = "";
cQAnswers[12] = "";
cQAnswers[13] = "";
cQAnswers[14] = "";

questions_txt.text = aQuestions [nQNumber];

submit_btn.addEventListener(MouseEvent.CLICK, quiz);

function quiz(e:MouseEvent):void 
{
     aUserAnswers.push(answers_txt.text);
     answers_txt.text = "";
     nQNumber++;
     if(nQNumber < aQuestions.length) 
     {
          questions_txt.text = aQuestions[nQNumber];
     }
     else
     {
          nextFrame();
     }
}

The questions in the quotation marks in the array

1 个答案:

答案 0 :(得分:0)

您可以使用转义序列\n在文本中插入新行:

var textField:TextField = new TextField();
textField.text = "Line\nBreak";
addChild(textField);

enter image description here

查看转义序列图表here