テキストにマスク (3)
////////////////////////////////////////////////////////////////////////////////
// テキストにマスク (3)
//
// グラデーション・マスク
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=462
////////////////////////////////////////////////////////////////////////////////
/**
* Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/yLDh
*/
// forked from ProjectNya's テキストにマスク (1)
////////////////////////////////////////////////////////////////////////////////
// テキストにマスク (3)
//
// グラデーション・マスク
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=462
////////////////////////////////////////////////////////////////////////////////
package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.filters.BlurFilter;
[SWF(backgroundColor="#000000", width="465", height="465", frameRate="30")]
public class Main extends Sprite {
private var container:Sprite;
private var shape:Shape;
public function Main() {
//Wonderfl.capture_delay(1);
init();
}
private function init():void {
graphics.beginFill(0x000000);
graphics.drawRect(0, 0, 465, 465);
graphics.endFill();
//
container = new Sprite();
addChild(container);
container.graphics.beginFill(0x333399);
container.graphics.drawRect(0, 0, 465, 465);
container.graphics.endFill();
var label:Label = new Label(465, 465, Label.CENTER);
container.addChild(label);
label.textColor = 0xFFFFFF;
var str:String = "";
for (var n:uint = 0; n < 65; n++) {
str += "wonderfl ActionScript3.0 ";
}
label.text = str;
//
shape = new Shape();
addChild(shape);
shape.graphics.beginFill(0x000000);
shape.graphics.drawRoundRect(0, 0, 400, 400, 40);
shape.graphics.endFill();
shape.x = 32;
shape.y = 32;
shape.filters = [new BlurFilter(32, 32, 3)];
//
container.cacheAsBitmap = true;
shape.cacheAsBitmap = true;
container.mask = shape;
}
}
}
//////////////////////////////////////////////////
// Labelクラス
//////////////////////////////////////////////////
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFieldAutoSize;
import flash.text.AntiAliasType;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
class Label extends Sprite {
private var txt:TextField;
private static var fontType:String = "_ゴシック";
private var _width:uint = 20;
private var _height:uint = 20;
public static const LEFT:String = TextFormatAlign.LEFT;
public static const CENTER:String = TextFormatAlign.CENTER;
public static const RIGHT:String = TextFormatAlign.RIGHT;
public function Label(w:uint, h:uint, align:String = LEFT) {
_width = w;
_height = h;
draw(align);
}
private function draw(align:String):void {
txt = new TextField();
addChild(txt);
txt.width = _width;
txt.height = _height;
txt.autoSize = align;
txt.type = TextFieldType.DYNAMIC;
txt.selectable = false;
//txt.embedFonts = true;
//txt.antiAliasType = AntiAliasType.ADVANCED;
txt.multiline = true;
txt.wordWrap = true;
var tf:TextFormat = new TextFormat();
tf.font = fontType;
tf.size = 14;
tf.align = align;
txt.defaultTextFormat = tf;
textColor = 0x000000;
}
public function set text(param:String):void {
txt.text = param;
}
public function set textColor(param:uint):void {
txt.textColor = param;
}
}