package com.Tutorial
{
    import com.adamatomic.flixel.*;
    
    public class MenuState extends FlxState
    {
        
		[Embed(source = "../../data/mus/blip.mp3")] public static var SndOpen:Class;
		[Embed(source = "../../data/mus/test.mp3")] public static var SndMusic:Class;
		
		private var bClosing:Boolean;
		
        override public function MenuState():void
        {
			bClosing = false;
            this.add(new FlxText(40, 40, FlxG.width, 400, "Math\nLand", 0xffc35752, null, 64, "left")) as FlxText;
            this.add(new FlxText(120, 290 , FlxG.width, 8, "x to start", 0xffc35752, null, 24, "left")) as FlxText;
			FlxG.setMusic(SndMusic);
        }
        
        override public function update():void
        {
            if (FlxG.kA&&!bClosing)
            {
				bClosing = true;
                FlxG.quake(10,1);
				FlxG.play(SndOpen, 0.1);
				onFade();
            }
            
            super.update();
        }
        private function onFade():void
        {
			FlxG.level = 9;
			FlxG.oldlevel = 9;
            FlxG.switchState(IntroState);
        }
    }
}