宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > AS2与AS3技术

[AS3]as3控制TextField文字的大小

2016-10-13 00:16:48 点击量:15 标签: 收藏本文

[AS3]as3控制TextField文字的大小

  1.  package { 
  2.     import flash.display.Sprite; 
  3.     import flash.text.TextField; 
  4.     import flash.text.TextFieldAutoSize; 
  5.     import flash.text.TextFormat; 
  6.     public class TextFormatExample extends Sprite { 
  7.         private var label:TextField; 
  8.         public function TextFormatExample() { 
  9.             configureLabel(); 
  10.             setLabel("Hello World and welcome to the show"); 
  11.         } 
  12.         public function setLabel(str:String):void { 
  13.             label.text = str
  14.         } 
  15. //下面开始设定TextField 
  16.         private function configureLabel():void { 
  17. //下面的还是在TextField层面设定,这些对TextField都是全局有效的 
  18.             label = new TextField(); 
  19.             label.autoSize = TextFieldAutoSize.LEFT; 
  20.             label.background = true
  21.             label.border = true
  22. //开始设定TextFormat啦,就是文字格式 
  23.             var format:TextFormat = new TextFormat(); 
  24.             format.font = "Verdana"
  25.             format.color = 0xFF0000
  26.             format.size = 10
  27.             format.underline = true
  28. /* 
  29. 绑定TextField的默认样式为刚才的TextFormat的,当然你可以使用setTextFormat(format:TextFormat, beginIndex:int = -1, endIndex:int = -1),用这个你可以更方便控制样式的范围 
  30. */ 
  31.             label.defaultTextFormat = format
  32.             addChild(label); 
  33.         } 
  34.     } 

 

ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室