Tod*_*odd 1 flash actionscript-3
我的舞台上有一个textinput组件,实例名称为"myTxt"
我想在此文本字段的内容中添加一些左边距.我试过了:
myTxt.setStyle("textPadding", 5);
Run Code Online (Sandbox Code Playgroud)
但是除了左边填充之外,它还增加了top(我假设是底部和右边)填充.简单地在文本字段的内容中添加左边距的最佳方法是什么?
谢谢你的帮助!
您可以使用TextFormat对象.
var tf:TextFormat = new TextFormat();
tf.leftMargin = 5;
// if you have a bunch of special formatting for your TextField (fonts/sizes/etc )
// you will need to set it up here.
// If you just using the default text etc you don't need to do anything else.
// you can use defaultTextFormat so you don't ever have to worry about it.
// Just set it up once and it will keep the same formatting.
myTxt.defaultTextFormat = tf;
Run Code Online (Sandbox Code Playgroud)
编辑:添加了TextField和TextFormat的链接
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html
http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/TextFormat.html
更新:对于TextInput
import flash.text.TextFormat;
var tf:TextFormat = new TextFormat();
tf.leftMargin = 5;
myTxt.setStyle("textFormat", tf);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5548 次 |
| 最近记录: |