forked from: forked from: FontLoader
forked from forked from: FontLoader (diff: 13)
thanks to the free font authors!
ActionScript3 source code
/**
* Copyright FTMSuperfly ( http://wonderfl.net/user/FTMSuperfly )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/5ppa
*/
// forked from civet's forked from: FontLoader
// forked from mash's FontLoader
// thanks to the free font authors!
package
{
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flupie.textanim.*;
import caurina.transitions.Tweener;
import net.wonderfl.utils.FontLoader;
public class FlupieTextAnim extends Sprite
{
public function FlupieTextAnim()
{
Wonderfl.capture_delay(30);
var offset :int = 0;
var fonts :Array = ["Bebas","Aqua","Azuki","Cinecaption"];
fonts.forEach( function( font :String, i:int, a:Array ) :void {
var loader :FontLoader = new FontLoader;
loader.load( font );
loader.addEventListener( Event.COMPLETE, function(e :Event) :void {
var tf :TextField = fontedTextField( font );
tf.y = offset;
addChild( tf );
var anim :TextAnim = new TextAnim(tf);
anim.effects = myEffect;
anim.blocksVisible = false;
anim.anchorX = TextAnimAnchor.CENTER;
anim.anchorY = TextAnimAnchor.TOP;
anim.mode = TextAnimMode.RANDOM;
anim.split = TextAnimSplit.WORDS;
anim.start();
offset += 30;
});
});
}
private function fontedTextField( font :String ) :TextField {
var tf :TextField = new TextField;
tf.defaultTextFormat = new TextFormat( font, 16, 0x000000 );
tf.embedFonts = true;
tf.width = 465;
tf.text = "The quick fox jumps over the lazy brown dog. 1234567890";
return tf;
}
private function myEffect(block:TextAnimBlock):void {
block.scaleX = block.scaleY = 0;
block.rotation = -120;
Tweener.addTween(block, {rotation:0, scaleX:1, scaleY:1, time:2, transition:"easeoutelastic"});
}
}
}