1

将蒙版添加到具有动态文本字段的父精灵时,文本会失去抗锯齿。我怎样才能保持文本的抗锯齿,同时仍然对其父级应用蒙版,然后对其自身应用蒙版。

字体是嵌入的,并且文本字段将被动画化,因此它也必须与其父级一起被屏蔽。

替代文字

package
{   
import flash.display.Sprite;
import flash.display.Shape;
import flash.text.*;

public class Test extends Sprite
    {
    public function Test()
        {
        //Create Background Canvas
        var canvas:Sprite = new Sprite();
        canvas.graphics.beginFill(0xFF0000)
        canvas.graphics.drawRect(0, 0, 100, 100);

        //Create Dynamic Text
        var field:TextField = new TextField();
        field.width = 100;
        field.autoSize = TextFieldAutoSize.LEFT;
        field.selectable = false;
        field.text = "Dynamic\nText";

        var format:TextFormat = new TextFormat();
        format.font = "Myriad Pro";
        format.color = 0xFFFFFF;
        format.size = 14;
        field.setTextFormat(format);

        //Add Dynamic Text To Background Canvas
        field.x = canvas.width /2  - field.width / 2;
        field.y = canvas.height / 2 - field.height / 2;
        canvas.addChild(field);

        //Create Mask
        var canvasMask:Shape = new Shape();
        canvasMask.graphics.beginFill(0);
        canvasMask.graphics.drawRoundRect(0, 0, 100, 100, 50);

        //Add Background Canvas And Mask To Display List
//      canvas.mask = canvasMask;
//      addChild(canvasMask);
        addChild(canvas);
        }
    }
}
4

1 回答 1

1

这似乎与应用蒙版时将 TextField 缓存为位图的方式有关。实际上,只需切换 TextField 上的 cacheAsBitmap 属性,我就能重现相同的行为。

添加这些行似乎可以解决问题。

    field.embedFonts = true;
    field.antiAliasType = AntiAliasType.ADVANCED;
    //you can adjust the thickness & sharpness if needed
    field.thickness = 200;
于 2010-11-08T02:11:40.753 回答