实现代码如下:

var UI:UIComponent=new UIComponent();
nWidth=40;
nHeight=40;
var DrawPic:Sprite=new Sprite();
DrawPic.graphics.clear();
DrawPic.graphics.beginFill(0xffffff);
DrawPic.graphics.drawRect(0,0,nWidth,nHeight);
DrawPic.graphics.endFill();
//添加输出文本
var txtTemp : TextField= new TextField();
txtTemp.autoSize = "left";
txtTemp.text = "A";
var fmt : TextFormat = new TextFormat();
fmt.size = 18;
txtTemp.setTextFormat(fmt);
txtTemp.x = DrawPic.x + (DrawPic.width - txtTemp.width) /2;
txtTemp.y = DrawPic.y + (DrawPic.height - txtTemp.height) / 2;
UI.addChild(DrawPic);
UI.addChild(txtTemp);
this.addChild(UI);

以上代码转自网络。

相关文章:

  • 2022-02-08
  • 2021-12-19
  • 2021-12-21
  • 2022-12-23
  • 2021-11-17
  • 2021-07-06
  • 2022-01-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-03
  • 2022-01-18
  • 2021-06-01
  • 2021-12-14
  • 2021-12-03
  • 2021-06-30
相关资源
相似解决方案