In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Text Mask 2010-2-16

TextMask
参考:http://d.hatena.ne.jp/nitoyon/20090909/text_mask
Get Adobe Flash player
by Makoto_Tanaka 15 Feb 2010
    Embed
/**
 * 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();
        		}
        }
    }
}