2016-10-13 00:16:48 点击量:15 标签: 收藏本文
[AS3]as3控制TextField文字的大小
- package {
- import flash.display.Sprite;
- import flash.text.TextField;
- import flash.text.TextFieldAutoSize;
- import flash.text.TextFormat;
- public class TextFormatExample extends Sprite {
- private var label:TextField;
- public function TextFormatExample() {
- configureLabel();
- setLabel("Hello World and welcome to the show");
- }
- public function setLabel(str:String):void {
- label.text = str;
- }
- //下面开始设定TextField
- private function configureLabel():void {
- //下面的还是在TextField层面设定,这些对TextField都是全局有效的
- label = new TextField();
- label.autoSize = TextFieldAutoSize.LEFT;
- label.background = true;
- label.border = true;
- //开始设定TextFormat啦,就是文字格式
- var format:TextFormat = new TextFormat();
- format.font = "Verdana";
- format.color = 0xFF0000;
- format.size = 10;
- format.underline = true;
- /*
- 绑定TextField的默认样式为刚才的TextFormat的,当然你可以使用setTextFormat(format:TextFormat, beginIndex:int = -1, endIndex:int = -1),用这个你可以更方便控制样式的范围
- */
- label.defaultTextFormat = format;
- addChild(label);
- }
- }
- }
我们是一家提供综合软件外包与弱电工程服务的技术公司。
业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。
公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室