多模块ModuleLoader思路演变

版本一:
<fx:Script>
		<![CDATA[
			
		private function init():void
		{
			setPanel("home");
		}
			
		public function setPanel(type:String):void
		{
			switch(type){
				
				case "home":
					this.myViewStack.selectedChild=home;
					this.title="首页";
					break;
				case "bio":
					this.myViewStack.selectedChild=bio;
					this.title="个人档";
					break;
				case "log":
					this.myViewStack.selectedChild=log;	
					this.title="日志";
					break;
				case "music":
					this.myViewStack.selectedChild=music;
					this.title="音乐盒";
					break;
				case "album":
					this.myViewStack.selectedChild=photo;
					this.title="相册";
					break;
				case "leavewords":
					this.myViewStack.selectedChild=leaveWords;
					this.title="留言板";
					break;
				case "game":
					this.myViewStack.selectedChild=game;
					this.title="小游戏";
					break;
				default:
					break;
			}
			
		}
		]]>
	</fx:Script>
	<mx:ViewStack id="myViewStack" width="100%" height="100%" >
		<mx:Box id="home"  width="100%" height="100%" verticalScrollPolicy="on" horizontalScrollPolicy="off">
			<module:XModuleLoader  url="com/dreamer/module/ModuleHome.swf"/>
		</mx:Box>
		
		<mx:Box id="bio"  width="100%" height="100%"  horizontalScrollPolicy="off">	
			<module:XModuleLoader url="com/dreamer/module/ModuleBio.swf" />
		</mx:Box>
		
		<mx:Box id="log"  width="100%" height="100%" horizontalScrollPolicy="off">	
			<module:XModuleLoader  url="com/dreamer/module/ModuleLog.swf"/>
		</mx:Box>
		
		<mx:Box id="music"  width="100%" height="100%" horizontalScrollPolicy="off">	
			<module:XModuleLoader  url="com/dreamer/module/ModuleMusic.swf" />
		</mx:Box>
		
		<mx:Box id="photo"  width="100%" height="100%" horizontalScrollPolicy="off">
			<module:XModuleLoader  url="com/dreamer/module/ModulePhoto.swf" />
		</mx:Box>
		
		<mx:Box id="leaveWords"  width="100%" height="100%" horizontalScrollPolicy="off">
			<module:XModuleLoader url="com/dreamer/module/ModuleLeaveWords.swf"/>
		</mx:Box>
		
		<mx:Box id="game"  width="100%" height="100%" horizontalScrollPolicy="off">
			<module:XModuleLoader  url="com/dreamer/module/ModuleGame.swf"/>
		</mx:Box>
	</mx:ViewStack>


版本二:
<fx:Script>
		<![CDATA[

			private function init():void
			{
				setPanel("home");
			}
				
			public function setPanel(type:String):void
			{
				this.currentState = type;
			}
		]]>
	</fx:Script>
	
	<fx:Declarations>
		<s:State name="home" />
		<s:State name="bio" />
		<s:State name="log" />
		<s:State name="music" />
		<s:State name="album" />
		<s:State name="leavewords" />
		<s:State name="game" />
	</fx:Declarations>
	
	<module:XModuleLoader url="com/dreamer/module/ModuleHome.swf" includeIn="home" verticalScrollPolicy="on" horizontalScrollPolicy="off"/>
	<module:XModuleLoader url="com/dreamer/module/ModuleBio.swf" includeIn="bio"  horizontalScrollPolicy="off"/>
	<module:XModuleLoader url="com/dreamer/module/ModuleLog.swf" includeIn="log" horizontalScrollPolicy="off"/>
	<module:XModuleLoader url="com/dreamer/module/ModuleMusic.swf" includeIn="music" horizontalScrollPolicy="off"/>
	<module:XModuleLoader url="com/dreamer/module/ModulePhoto.swf" includeIn="album" horizontalScrollPolicy="off"/>
	<module:XModuleLoader url="com/dreamer/module/ModuleLeaveWords.swf" includeIn="leavewords" horizontalScrollPolicy="off"/>
	<module:XModuleLoader url="com/dreamer/module/ModuleGame.swf" includeIn="game" horizontalScrollPolicy="off"/>

你可能感兴趣的:(游戏,Flex,音乐)