package {
	import jp.progression.casts.*;
	import jp.progression.commands.display.*;
	import jp.progression.commands.lists.*;
	import jp.progression.commands.net.*;
	import jp.progression.commands.tweens.*;
	import jp.progression.commands.*;
	import jp.progression.data.*;
	import jp.progression.events.*;
	import jp.progression.executors.*;
	import jp.progression.scenes.*;
	import caurina.transitions.Equations;
	//
	import flash.events.MouseEvent;
	import flash.display.MovieClip;
	import scenes.*;
	import pages.*;
	import ui.*;
	/**
	 * ...2009.10.10
	 * @oshige ...
	 */
	public class IndexScene extends SceneObject {
		private var uiPanel:CastSprite;
		private var logo:MovieClip;
		
		public function IndexScene() {
			// このシーンタイトル -- ブラウザタイトルバーの表示
			title = "top";
			//このシーンの中身
			logo = new oshigeLogo();
			//子シーンを追加する
			var sceneA:TheScene = new TheScene("sceneA",{title:"top | A", url:"pages_swf/pageA.swf"});
			var sceneB:TheScene = new TheScene("sceneB",{title:"top | B", url:"pages_swf/pageB.swf"});
			var sceneC:TheScene = new TheScene("sceneC",{title:"top | C", url:"pages_swf/pageC.swf"});
			addScene(sceneA);
			addScene(sceneB);
			addScene(sceneC);
			
			//共通のuiを追加する
			var container_ui:CastSprite = new CastSprite();
			container.addChildAt(container_ui,5);
			uiPanel = new UIPanel();
			uiPanel.x = (stage.stageWidth- uiPanel.width)/2;
			uiPanel.y = stage.stageHeight + 50;
			container_ui.addChild(uiPanel);
		}

		//クリックで最初の子シーンへ移動
		private function mouseDownHandler(eventObj:MouseEvent):void {
			manager.goto(self.scenes[0].sceneId);
		}
		//シーンを読み込む
		protected override function atSceneLoad():void {
				addCommand(
							new Prop(logo,{x:150, y:100, scaleX:2, scaleY:2, alpha:0}),
						    new AddChildAt(container, logo, 4),
						   	new DoTweener(logo, {alpha:1, time:1})  		 
				);
		}
		//シーンに入る enterScene
		protected override function atSceneInit():void {
			stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
			//シーンにパネル退場, ロゴはセンターへ
			addCommand(
					new DoTweener( uiPanel, { y:stage.stageHeight +50, time:1 } ),
					new DoTweener(logo,{x:150, y:100, scaleX:2, scaleY:2,time:1})
			);
		}
		//シーンを抜ける exitScene
		protected override function atSceneGoto():void {
			stage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
			//シーンからロゴ退場、パネル登場
			addCommand(
				new DoTweener(logo,{x:30, y:30, scaleX:1, scaleY:1,time:1}),
				new DoTweener( uiPanel, { y:stage.stageHeight - 60, time:1 } )
			);
		}
		//シーンから完全に出た
		protected override function atSceneUnload():void {
			stage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
			//シーンからロゴ退場、パネル登場
			addCommand(
				new DoTweener(logo,{x:30, y:30, scaleX:1, scaleY:1,time:1}),
				new DoTweener( uiPanel, { y:stage.stageHeight - 60, time:1 } )
			);
		}
	}
}