将掩码添加到具有动态文本字段的父精灵时,文本将失去抗锯齿功能。如何保持文本的反别名,同时仍然将掩码应用于其父级,然后再应用于自身。
嵌入了字体,文本字段将被设置为动画,因此它也必须与其父字符一起被屏蔽。
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);
}
}
}
答案 0 :(得分:1)
这似乎与应用蒙版时TextField缓存为Bitmap的方式有关。实际上,我只需通过切换TextField上的cacheAsBitmap属性就能重现相同的行为。
添加这些线似乎可以解决问题。
field.embedFonts = true;
field.antiAliasType = AntiAliasType.ADVANCED;
//you can adjust the thickness & sharpness if needed
field.thickness = 200;