不像我使用此代码那样处于任何部分(包括单词的中间部分):
var answer:TextField = new TextField();
var textFormat:TextFormat = new TextFormat();
textFormat.size=15;
textFormat.color=0x7E7E7E;
textFormat.font="Vrinda";
answer.defaultTextFormat=textFormat;
answer.selectable=false;
answer.text=currentQuestion.answers[k];
answer.width=600;
answer.x=54;
answer.y=110+k*(40)+addPixels;
answers.push(answer);
answer.multiline=true;
answer.wordWrap = true;
answer.autoSize = TextFieldAutoSize.LEFT;
answer.addEventListener(MouseEvent.CLICK, selectViaText)
addChild(answer);
我在说新线。
答案 0 :(得分:1)
textfield.multiline=true;
和wordWrap
autoSize
这对我来说很好,生成400宽度的包装文本:
import flash.text.TextField;
var t:TextField = addChild(new TextField()) as TextField;
t.wordWrap = true;
t.width = 400;
t.autoSize = TextFieldAutoSize.LEFT;
t.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut varius eros id massa auctor tempus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse fermentum aliquet consequat. Nulla non est massa, ut viverra nisi. Cras ligula risus, dignissim non semper vitae, cursus sit amet sem. Vivamus bibendum porta vestibulum. Etiam porttitor elit eu turpis cursus lobortis. Mauris vestibulum pulvinar varius. Maecenas non sodales erat. Praesent id augue mi, nec laoreet diam. Fusce ultrices quam varius enim ultricies nec sagittis risus laoreet. Vestibulum ullamcorper feugiat varius. ";
呈现为:
......确实只包装在空格上。