package com.Tutorial
{
    import com.adamatomic.flixel.*;
    
    public class MenuState extends FlxState
    {
        
		[Embed(source = "../../data/blip.mp3")] private var SndOpen:Class;
		[Embed(source = "../../data/title.mp3")] private var SndMusic:Class;
		
		private var bClosing:Boolean;
		
        override public function MenuState():void
        {
			bClosing = false;
            this.add(new FlxText(10, 80, FlxG.width, 80, "Missing", 0xffffffff, null, 16, "left")) as FlxText;
            this.add(new FlxText(10, 125 , FlxG.width, 8, "x to start", 0xffffffff, null, 8, "left")) as FlxText;
			FlxG.setMusic(SndMusic);
        }
        
        override public function update():void
        {
            if (FlxG.kA&&!bClosing)
            {
				bClosing = true;
                FlxG.flash(0xffffffff, 0.75);
                FlxG.fade(0xff000000, 1, onFade);	
				FlxG.play(SndOpen,0.1);
            }
            
            super.update();
        }
        private function onFade():void
        {
			FlxG.level = 0;
			FlxG.stopMusic();
            FlxG.switchState(IntroState);
        }
    }
}