Hello,world. - random timing

by esukei forked from Hello,World. (diff: 21)
just shows 'Hello,World'
@author Esukei
♥0 | Line 39 | Modified 2008-12-19 10:49:39 | MIT License
play

ActionScript3 source code

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

// forked from esukei's Hello,World.
package
{
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.TextFieldAutoSize;
    import flash.events.Event;

    [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="30")]

    /**
     * just shows 'Hello,World'
     * @author Esukei
     */
    public class HelloWorld extends MovieClip
    {

        private var textField:TextField = new TextField();
        private var textFormat:TextFormat = new TextFormat();
        private var text:String;

        public function HelloWorld()
        {
            textFormat.font = "Arial";
            textFormat.color = 0xFFFFFF;
            textFormat.size = 10;
            textField.autoSize = TextFieldAutoSize.LEFT;
            textField.defaultTextFormat = textFormat;
            textField.text = '';
            text = 'Hello, world.\nHello, world.\nHello, world.\nHello, world.\nHello, world.\nHello, world.\nHello, world.\nHello, world.\nHello, world.\nHello, world.\nHello, world.\nHello, world.\n';
            addChild(textField);
            addEventListener(Event.ENTER_FRAME,function(event:Event):void
            {
                if(Math.random() > 0.8)
                {
                    textField.appendText( text.charAt(0) );
                    text = text.substring(1,text.length);
                    if( text.length == 0 )
                    {
                        removeEventListener(Event.ENTER_FRAME,arguments.callee);
                    }
                }
            });
        }
    }
}