package net.fdms.Database 
{
	import com.greensock.events.LoaderEvent;
	import com.greensock.loading.XMLLoader;
	import net.fdms.Database.Games.GamesData;
	import net.fdms.Function.MarryTimer;
	/**
	 * 2011/5/16 9:35
	 * @author Dawnboy
	 */
	public class AnalysisData 
	{
		private static var loader:XMLLoader = null;
		public function AnalysisData() 
		{
			
		}
		
		/**
		 * 解析数据
		 * @param	dataSets
		 */
		public static function init(dataSets:*):void {
			if (dataSets is XML && dataSets != XML(undefined)) {
				analysis(dataSets);
			}else if(dataSets is String && dataSets!=""){
				loadXML(dataSets);
			}else {
				trace("DataXML does not exits!");
			}

		}
		
		/**
		 * 分析数据
		 * @param	data
		 */
		private static function analysis(data:XML):void {
			if (data.wedday != XMLList(undefined)) MarryTimer.init(data.wedday.text().toString());
			if (data.home != XMLList(undefined)) MarryInfo.init(data.home);
			if (data.photo != XMLList(undefined)) PhotoData.init(data.photo);
			if (data.video != XMLList(undefined)) VideoData.init(data.video);
			if (data.diary != XMLList(undefined)) DiaryData.init(data.diary);
			if (data.life != XMLList(undefined)) GamesData.init(data.life);
			if (data.feel != XMLList(undefined)) FeelData.init(data.feel);
			if (data.wish != XMLList(undefined)) WishData.init(data.wish);
			if (data.baby != XMLList(undefined)) BabyData.init(data.baby);
		}
		
		private static function loadXML(src:String):void {
			loader = new XMLLoader(src, { onComplete:onComplete, onError:loadErr } );
			loader.load();
		}
		
		private static function onComplete(e:*):void {
			trace(e.target.content);
			analysis(e.target.content);
		}
		/**
		 * 数据载入出错
		 * @param	evt
		 */
		private static function loadErr(evt:LoaderEvent):void {
			trace("loaderErr")
		}
		
		
		
		
	}

}