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

020310

Get Adobe Flash player
by hirayu 21 Oct 2011
    Embed
/**
 * Copyright hirayu ( http://wonderfl.net/user/hirayu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6D1X
 */

package {
    import flash.text.engine.TextLine;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    import flash.ui.Mouse;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.events.MouseEvent;
    
    public class MyTextField extends Sprite {
        public var fld:TextField;
        public var msg:String;
        public var timer:Timer;
        public function MyTextField() {
            var tf:TextFormat = new TextFormat();
            tf.font = "_typewtiter";
            tf.size = 18;
            tf.color = 0x0000FF;
            fld = new TextField();
            fld.x = 50;
            fld.y = 50;
            fld.autoSize = TextFieldAutoSize.LEFT;
            fld.background = true;
            fld.backgroundColor = 0xFFFF00;
            fld.defaultTextFormat = tf;
            msg = "楽しいActionScriptの世界へ";
            addChild(fld);
            fld.selectable = false;
            fld.addEventListener(MouseEvent.ROLL_OUT,rollOutHandler);
            fld.addEventListener(MouseEvent.ROLL_OVER,rollOverHandler);
            timer = new Timer(100,fld.length);
            timer.addEventListener(TimerEvent.TIMER,timerHandler);
            timer.start();
        }
        public function timerHandler(event:TimerEvent):void {
            var char:String = msg.charAt(timer.currentCount-1);
            fld.appendText(char);
        }

        public function rollOverHandler(event:MouseEvent):void {
            fld.textColor = 0xFFFFFF;
            fld.backgroundColor = 0x009900;
        }
        public function rollOutHandler(event:MouseEvent):void {
            fld.textColor = 0x000000;
            fld.backgroundColor = 0xFFFFFF;
        }

    }
}