flash on 2009-9-9
/**
* Copyright pasodania ( http://wonderfl.net/user/pasodania )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/bkkl
*/
package {
import flash.display.*;
import flash.events.Event;
import flash.text.*;
[SWF(backgroundColor="#FFFFFF", width="450", height="80")]
public class EasyDynamicTextMask extends Sprite {
public function EasyDynamicTextMask() {
// write as3 code here..
stage.scaleMode = "noScale";
// Show original Text(input)
var text:TextField = new TextField();
text.type = "input";
text.autoSize = "left";
text.htmlText = <font size="50" color="#000000">HELLO WORLD</font>.toXMLString();
addChild(text);
// Create Spirte
var sprite:Sprite = new Sprite();
addChild(sprite);
// Set text as Mask
sprite.mask = text;
text.cacheAsBitmap = sprite.cacheAsBitmap = true;
// Draw Sprite
addEventListener("enterFrame", function(e:Event):void{
sprite.graphics.beginFill(Math.random() * 0xFFFFFF);
sprite.graphics.drawCircle(Math.random() * 450, Math.random() * 80, Math.random() * 50);
sprite.graphics.endFill();
if( Math.random() < .02){
sprite.graphics.clear();
}
});
}
}
}