package com.Tutorial 
{
    import com.adamatomic.flixel.*;
	/**
	 * ...
	 * @author Stephen Lavelle
	 */
	public class IntroState extends FlxState
	{
		[Embed(source = "../../data/game.mp3")] private var SndMus:Class;
		
		private var _nPageNum:Number;
		private var _pressed:Boolean;
		private var prefactoryMonologue:Array
		private var _label:FlxText;
		
		public function IntroState():void
		{			
			FlxG.stopMusic();
			FlxG.setMusic(SndMus);
			
			_nPageNum = 0;
				
			prefactoryMonologue = new Array("Six year ago now,",
												  "Six years of long aching,",
												  "Six years of sorrow,",
												  "One autumn day,",
												  "Six years ago,",
												  "One day in August,",
												  "Did my young boy vanish.",
												  "",
												  "Since then,",
												  "Since I have been looking,",
												  "I have looked for my boy,",
												  "Ever since he vanished",
												  "",
												  "Every few of years I move,",
												  "I move to a new town,",
												  "Every few years.",
												  "I hope I will see him there,",
												  "In the town I'm in.",
												  "",
												  "I ask people,",
												  "I ask people in the new town,",
												  "I ask them if they,",
												  "If they have seen him.",
												  "",
												  "He must be much taller now,",
												  "No doubt quite handsome,",
												  "Handsome like his father.",
												  "",
												  "I will keep on looking,",
												  "Until I find him,",
												  "Until my son I find."
											
												  );
												
			_label = new FlxText(00, 40,150, 150, prefactoryMonologue[0], 0xff0000ff, null, 8, "center");			
			this.add(_label) as FlxText;
		}
		
		
        override public function update():void
		{
			if (FlxG.justPressed(FlxG.A) || FlxG.justPressed(FlxG.B))
			{
				_nPageNum++;
				trace(_nPageNum);
				trace(prefactoryMonologue.length);
				if (_nPageNum < prefactoryMonologue.length)
				{
					_label.setText(prefactoryMonologue[_nPageNum]);
				}
				else
				{
					FlxG.fade(0xff000000, 3, onFade);	
				}
			}

			super.update();
		}
		
        private function onFade():void
        {
			FlxG.level = 0;
            FlxG.switchState(PlayState);
        }
	}

}