• as3.0 文本(TextField)内容居中显示


    as3.0文本居中显示很费事,不像html那样简单,必须具备3个条件

    1、设置文本样式的属性 TextFormat 居中

    2、设置文本宽度

    3、文本内容必须用text属性而不能用htmlText属性

    4、文本宽度 必须在text属性之前设置

    实例如下:

    package MC.QQMC.QQShare
    {
       import flash.text.TextField;
       import flash.text.TextFormat;
       public class OneShareMC extends MovieClip
       {
        private var txtform:TextFormat;
        public function OneShareMC()
        {

         //设置文本居中属性
           txtform=new TextFormat();
           txtform.align="center";

           var numTxt:TextField= new TextField();
           numTxt.textColor=0x00ff00;
           numTxt.defaultTextFormat=txtform;
           numTxt.width=45;//宽度一定要有而且 宽度一定要再 text 赋内容之前

         numTxt.background=true;
           numTxt.backgroundColor=0x121313;
           numTxt.border=true;
           numTxt.borderColor=0x3c3e2e;
           numTxt.selectable=false;//
           numTxt.text = "文本显示内容";//顺序很重要
      }
     
     }
    }

  • 相关阅读:
    [编程题]多多的数字组合
    mac传输文件到服务器
    git 清除缓存、查看add内容
    go build
    vim编辑器
    Git: clone指定分支
    查看端口占用以及kill
    curl小记录
    Python3.9 malloc error: can’t allocate region
    设计模式-策略模式
  • 原文地址:https://www.cnblogs.com/attesa/p/3210605.html
Copyright © 2020-2023  润新知