forked from: flash on 2009-8-17

by kanatara
♥0 | Line 55 | Modified 2010-08-13 12:55:09 | MIT License
play

ActionScript3 source code

/**
 * Copyright kanatara ( http://wonderfl.net/user/kanatara )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7pwI
 */

// forked from kidaipu's flash on 2009-8-17
package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.TimerEvent;
    import flash.filters.BlurFilter;
    import flash.geom.Point;
    import flash.text.AntiAliasType;
    import flash.text.Font;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.utils.Timer;

    [SWF(width = "500", height = "500", frameRate = "72", backgroundColor = "#ffffff")]
    public class ColorFont extends Sprite
    {
        private var base:Sprite;
        private var txt:TextField;
        private var bmp:Bitmap;
        
        //コンストラクタ    
        public function ColorFont()
        {
            base = new Sprite();
            base.x = 120;
            base.y = 120;
            addChild(base);
            
            //テキストフィールド
            txt = new TextField();
            txt.text = "X";
            txt.antiAliasType = AntiAliasType.ADVANCED;
            txt.autoSize = "left";
            
            //フォント
            var aFonts:Array = Font.enumerateFonts(true);
            var fnt:Font = aFonts[13];
            var tf:TextFormat = new TextFormat();
            tf.font = fnt.fontName;
            tf.size = 100;
            tf.bold = true;
            tf.color = 0xcccc00;
            txt.setTextFormat(tf, 0, txt.length); //フォントセット
            
            //ビットマップデータ
            var bd:BitmapData = new BitmapData(txt.width, txt.height, false, 0xffffff);
            bd.draw(txt);
            bd.applyFilter(bd, bd.rect, new Point(), new BlurFilter(2,2,1));
            bd.draw(txt);

            //ビットマップ
            bmp = new Bitmap(bd);
            bmp.alpha = 0.5;
            bmp.x = -25;
            bmp.y = -25;
            base.addChild(bmp);
            
            //タイマー
            var timer:Timer = new Timer(50, 0);
            timer.addEventListener(TimerEvent.TIMER,Loop);
            timer.start();   
        }
        
        //ループ
        private function Loop(e:TimerEvent):void
        {
            bmp.rotation += 10.0;
        }
    }
}

Forked