// vim:syntax=javascript

class TitleScreen extends MovieClip {
    static var INITIAL_DELAY_FRAMES : Number = 24*4;
    static var FADE_OMEGA : Number = Math.PI/48;

    var _prompt_name : String = "prompt_txt";
    var _delay_frames : Number;
    var _fade_frame_count : Number

    function onLoad () {

        var txt_fmt = new TextFormat();
        with (txt_fmt) {
            font = "Vera";
            size = 25;
            color = 0x000000;
            align = "center";
        }

        this.createTextField(_prompt_name, 100, 0, 220, 400, 30);

        var tf:TextField = this[_prompt_name];
        with (tf) {
            embedFonts = true;
            setNewTextFormat(txt_fmt);
            setTextFormat(txt_fmt);
            text = "Click to Rock!";
            _alpha = 0;
        }

        _delay_frames = INITIAL_DELAY_FRAMES;
        _fade_frame_count = 0;
    }

    function onEnterFrame() {

        if (_delay_frames > 0) {
            _delay_frames --;
        } else {
            var s = Math.sin(FADE_OMEGA*_fade_frame_count);
            this[_prompt_name]._alpha = s * s * 100;

            _fade_frame_count ++;
        }
    }
}
