Text Mask 2010-2-16
TextMask
参考:http://d.hatena.ne.jp/nitoyon/20090909/text_mask
/**
* Copyright Makoto_Tanaka ( http://wonderfl.net/user/Makoto_Tanaka )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/GxfP
*/
// TextMask
// 参考:http://d.hatena.ne.jp/nitoyon/20090909/text_mask
//
package {
import flash.text.TextField;
import flash.display.Sprite;
import flash.events.Event;
public class FlashTest extends Sprite {
private var _sprite:Sprite;
public function FlashTest() {
var text:TextField = new TextField();
text.type = "input";
text.autoSize = "left";
text.htmlText = <font size="50" color="#000000">Hello World</font>.toXMLString();
addChild(text);
_sprite = new Sprite();
addChild(_sprite);
_sprite.mask = text;
text.cacheAsBitmap = true;
_sprite.cacheAsBitmap = true;
addEventListener("enterFrame", onEnterFrame);
}
private function onEnterFrame(e:Event):void {
_sprite.graphics.beginFill(Math.random() * 0xffffff);
_sprite.graphics.drawCircle(Math.random() * 450, Math.random() * 80, Math.random() * 70);
_sprite.graphics.endFill();
if (Math.random() < 0.2) {
_sprite.graphics.clear();
}
}
}
}