TextFieldでGradientFillしたい
maskはなんとなくダサい気がする
package {
import flash.display.BitmapData;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.Sprite;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
[SWF(width=465,height=465,backgroundColor=0x0)]
public class ASTest extends Sprite{
public function ASTest() {
init();
}
private function init():void
{
var tf:TextField = addChild(new TextField()) as TextField;
tf.autoSize = TextFieldAutoSize.LEFT;
var format:TextFormat = new TextFormat();
format.size = 100;
format.font = 'A-OTF 新ゴ Pro';
tf.defaultTextFormat = format;
tf.text = '魔法少女';
tf.y = 100;
tf.cacheAsBitmap = true;
this.cacheAsBitmap = true;
this.mask = tf;
var matrix:Matrix = new Matrix();
matrix.createGradientBox(tf.width/2,tf.height/2,Math.PI/2,tf.x,tf.y);
this.graphics.beginGradientFill(GradientType.LINEAR,[0x880000,0xffdddd],[1,1],[40,230],matrix,SpreadMethod.REFLECT);
this.graphics.drawRect(tf.x,tf.y,tf.width,tf.height);
this.graphics.endFill();
}
}
}