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

あずきフォントで遊ぼう

textanimでテキストを動かす LIVE CODING 2010/07/31 17:21-22:07
画面クリックで文字?が出てきます
Get Adobe Flash player
by shohei909 31 Jul 2010
/**
 * Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/f98N
 */

//textanimでテキストを動かす LIVE CODING 2010/07/31 17:21-22:07

//画面クリックで文字?が出てきます

package {
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.text.*;
    
    import flupie.textanim.*;
    import caurina.transitions.Tweener;
    import net.wonderfl.utils.FontLoader;
    
    public class FlashTest extends Sprite {
        static private const TF1:Array = [  ["embedFonts",true], ["text","あずきフォントで遊ぼう!!"],["autoSize",TextFieldAutoSize.LEFT], ["x",45],["y",20],["selectable",false]   ];
        static private const FR1:Array = [  ["font","Azuki"], ["size",30], ["color",0x660033] ];
        
        static private const TF2:Array = [  ["embedFonts",true], ["text","特殊文字"],["autoSize",TextFieldAutoSize.LEFT], ["x",0],["y",80],["selectable",false]  ];
        static private const FR2:Array = [  ["font","Azuki"], ["size",36], ["color",0x000000] ]; 
        
        static private const TF3:Array = [  ["embedFonts",true], ["text","─│┌┐┘└├┬┤┴┼━┓┛┣\n┗┳┫┻╋┠┯┨┷┿┝┰┥┸╂"], ["autoSize",TextFieldAutoSize.LEFT], ["backgroundColor",0xFFCCCC], ["background",true], ["x",160],["y",80],["selectable",false]  ];
        static private const FR3:Array = [  ["font","Azuki"], ["size",18], ["color",0x000000] ];
        
        static private const TF4:Array = [  ["embedFonts",true], ["text","┐─────────────────┌"],["autoSize",TextFieldAutoSize.LEFT], ["x",0],["y",0],["selectable",true]  ];
        static private const FR4:Array = [  ["font","Azuki"], ["size",24], ["color",0x000000] ];
        
        static private const TF5:Array = [  ["embedFonts",true], ["text","┐─────────────────┌"],["autoSize",TextFieldAutoSize.LEFT], ["x",0],["y",50],["selectable",true]  ];
        
        static private const TF6:Array = [  ["embedFonts",true], ["text","┬┬┬┬"],["autoSize",TextFieldAutoSize.LEFT], ["x",50],["y",250],["selectable",true]  ];
        static private const FR6:Array = [  ["font","Azuki"], ["size",72], ["color",0x1B1B1B ]];
        
        static private const STR:String = "─│┌┐┘└├┬┤┴┼━┓┛┣┗┳┫┻╋┠┯┨┷┿┝┰┥┸╂";
        
        private var anim2 :TextAnim;
        private var big:TextField = new TextField();
        private const EFFECT_DATA:Vector.<Function> = Vector.<Function>([
            fadeDown,random,slide,front,cut,spin
        ]);
        private const MODE_DATA:Vector.<String> = Vector.<String>(["edgestocenter","centertoedge","random","lastToFirst","firstToLast"]);
        
        public function FlashTest() {
            Wonderfl.capture_delay(2);
            
            var fl :FontLoader = new FontLoader();
            fl.load( "Azuki" );
            fl.addEventListener( Event.COMPLETE, init );
        }
        
        private function init(e:Event):void{
            var title:TextField = TFUtil.textField(TF1,FR1);
            var tf2:TextField = TFUtil.textField(TF2,FR2);
            var tf3:TextField = TFUtil.textField(TF3,FR3);
            var line:TextField = TFUtil.textField(TF4,FR4);
            var line2:TextField = TFUtil.textField(TF5,FR4);
            big = TFUtil.textField(TF6,FR6);
            
            addChild(title);
            addChild(line);
            addChild(line2);
            addChild(tf2);
            addChild(tf3);
            addChild(big);
            
            var anim1 :TextAnim = new TextAnim(title);
            anim1.effects = myEffect;
            anim1.blocksVisible = false;
            anim1.start();
            
            anim2 = new TextAnim(big);
            anim2.blocksVisible = false;
              
            stage.addEventListener("mouseDown",mouseDown);
        }
        
        private function myEffect(block:TextAnimBlock):void {
            move();
            block.scaleX = block.scaleY = 0;
            Tweener.addTween(block, {scaleX:1, scaleY:1, time:2, transition:"easeoutelastic"});
        }
        private function fadeDown(block:TextAnimBlock):void {
            var by:int =  block.y;
            block.y = -30; block.alpha = 0;
            Tweener.addTween(block, {alpha:1, y:by, time:2, transition:"easeOutBounce"});
        }
        private function random(block:TextAnimBlock):void {
            var by:int=block.y;var bx:int=block.x;
            block.x = bx+300*(Math.random()-0.5); block.y = by+300*(Math.random()-0.5);
            block.scaleX = block.scaleY = Math.random()*0.8 + 0.2;
            block.rotation = 100*(Math.random()-0.5);
            Tweener.addTween(block, {scaleX:1, scaleY:1, rotation:0, alpha:1, x:bx, y:by, time:2, transition:"easeinoutBack"});
        }
        private function slide(block:TextAnimBlock):void {
            var bx:int=block.x;
            block.x = -200;
            Tweener.addTween(block, {x:bx, time:2, transition:"easeoutBack"});
        }
        private function front(block:TextAnimBlock):void {
            var by:int=block.y;var bx:int=block.x;
            block.scaleX = block.scaleY = 3;
            block.x = bx+30*(Math.random()-0.5); block.y = by+30*(Math.random()-0.5);
            Tweener.addTween(block, { scaleX:1, scaleY:1, time:.5, delay:.5, x:bx, y:by, transition:"easeInOutSine"});
        }
        private function spin(block:TextAnimBlock):void {
            block.rotation = 0;
            Tweener.addTween(block, { delay:.5, rotation:int(Math.random()*4+1)*360,time:2, transition:"easeInOutSine"});
        }
        private function cut(block:TextAnimBlock):void {
            var by:int=block.y;var bx:int=block.x;
            block.x = 400 + 4*(Math.random()-0.5);
            block.y = 180 + 4*(Math.random()-0.5);
            Tweener.addTween(block, { delay:1, x:bx, y:by, time:0.3, transition:"easeInOutQuad"});
        }
        
        
        public function move():void{
            x = 1*(Math.random()-0.5);
            y = 1*(Math.random()-0.5);
            rotation = 1*(Math.random()-0.5);
        }

        
        private function mouseDown(e:Event):void{
            var i:int = STR.length * Math.random();
            var letter:String = STR.substr(i,1);;
            var index:int = STR.indexOf(letter);
            if(index<0){index=0}
            
            anim2.htmlText = letter+ '<font color=\"#d6156c\">' +letter+ '</font>' +letter+letter+letter;
            anim2.mode = MODE_DATA[index%MODE_DATA.length];
            anim2.effects = EFFECT_DATA[index%EFFECT_DATA.length];
            anim2.blocksVisible = false;
            anim2.start();
        }
        

    }
}







import flash.text.TextFormat
import flash.text.TextField;

class TFUtil{
    //行列に従ってパラメータを設定したTextFieldを返します。
    static public function textField(arr:Array,format:Array=null):TextField{
        var tf:TextField = new TextField();
        if(format!=null){tf.defaultTextFormat = TFUtil.format(format);}
        for(var i:int=0;i<arr.length;i++){tf[arr[i][0]]=arr[i][1];}
        return tf;
    }
    //行列に従ってパラメータを設定したTextFormatを返します。
    static public function format(arr:Array):TextFormat{
        var f:TextFormat = new TextFormat(); 
        for(var i:int=0;i<arr.length;i++){f[arr[i][0]]=arr[i][1];}
        return f;
    }
    
    //行列に従ってパラメータをobjに設定します。
    static public function push(obj:Object,arr:Array):void{
        for(var i:int=0;i<arr.length;i++){obj[arr[i][0]]=arr[i][1];}
    }
}