嵌入文字形状

| 我想将一些文本嵌入到ActionScript中的圆圈中。我遇到三个问题:无法使文本在圆中居中,无法使文本居中对齐,并且无法将字体应用于文本。关于字体,我知道它已正确嵌入,因为它可以在我在舞台上创建的ѭ0上工作。
[Embed(source=\"DAXCOMPL.TTF\", fontName=\"DaxCompact-Light\", mimeType=\'application/x-font\', embedAsCFF=\'false\')]
private var MyFont:Class;

public function Bubble(...) {
    var myFont:Font = new MyFont();

    var myFormat:TextFormat = new TextFormat();
    myFormat.size = 20;
    myFormat.align = TextFormatAlign.CENTER;
    myFormat.font = myFont.fontName;

    var circle:Sprite = new Sprite();
    var r:int = 30;
    var text:TextField = new TextField();
    text.text = \"Hello world!\";
    text.wordWrap = true;
    text.defaultTextFormat = myFormat;
    text.autoSize = TextFieldAutoSize.LEFT;
    text.x = -30;
    text.y = -30;

    circle.graphics.lineStyle(2, 0x000000, 1.0);
    circle.graphics.drawCircle(0,0,r);
    circle.graphics.endFill();
    circle.addChild(text);
    circle.x = 75;
    circle.y = 450;
    addChild(circle);
}
已邀请:
尝试以这种方式初始化文本字段:
var text:TextField = new TextField();
text.embedFonts = true; // use embedded font
text.defaultTextFormat = myFormat; // use this command before setting text
text.text = \"Hello world!\";
text.wordWrap = true;
text.autoSize = TextFieldAutoSize.LEFT;
text.x = -text.textHeight*0.5; //center the textfield after setting text
text.y = -text.textWidth*0.5;

要回复问题请先登录注册