Flash在中间的垂直文本对齐文本、Flash

由网友(真想一巴掌拍死自己)分享简介:我一直在寻找一种方式来编程,并默认设置一个动态文本框垂直对齐框的中间。我觉得真的很难相信,有没有选择这样做,除非我很过分盲目。否则我怎么能假的呢?谢谢!解决方案 VAR parentContainer:级DisplayObjectContainer = ...;VAR textField的:文本字段= ...;...

我一直在寻找一种方式来编程,并默认设置一个动态文本框垂直对齐框的中间。我觉得真的很难相信,有没有选择这样做,除非我很过分盲目。否则我怎么能假的呢?

谢谢!

解决方案

  VAR parentContainer:级DisplayObjectContainer = ...;
VAR textField的:文本字段= ...;
textField.autoSize = TextFieldAutoSize.CENTER;
//设置宽度,高度,将wordWrap等,如果需要

//设置文本后或在textInput事件处理程序,如果
// textField的是用户可编辑的
textField.y = parentContainer.height * 0.5  -  textField.textHeight * 0.5;
 

I've been looking for a way to programmatically and by default set a dynamic text box to vertically align in the middle of the box. I find it really hard to believe that there's no option to do this, unless I'm excessively blind. Else how can I fake it?

Word2007段落对齐方式的设置

Thanks!

解决方案

var parentContainer:DisplayObjectContainer = ...;
var textField:TextField = ...;
textField.autoSize = TextFieldAutoSize.CENTER; 
// set width, height, wordWrap etc if needed

//after setting the text or in the textInput event handler if the 
//textField is user editable
textField.y = parentContainer.height * 0.5 - textField.textHeight * 0.5;

阅读全文

相关推荐

最新文章