package net.fdms.Action 
{
	import flash.display.DisplayObject;
	import net.fdms.Function.Loader.Loader;
	import net.fdms.Resource.Resource;
	import net.fdms.Function.Align.AlignSets;
	/**
	 * ...
	 * @author Dawnboy
	 */
	public class ActionControl 
	{
		
		public function ActionControl() 
		{
			
		}
		
		public static function runAction(ActType:int, Target:String, param:* = null):void {
			var target:DisplayObject;
			switch(ActType) {
				case 0:
					Loader.addLoad([Target]);
					Loader.start();
					break;
				case 1:
					if(Resource.Status(Target)){
						ResControl.removeRes(Target);
					}
					break;
				case 2:
					ResStatus.change(Target, param);
					break;
				case 3:
					var config:Object = Resource.getConfig(Target);
					if (config) {
						
						target = Resource.getObject(Target);
						if (param) {
							if (config.alignSets) {
								if (param.align) {
									config.alignSets[0] = param.align;
								}
								if (param.style) {
									config.alignSets[1] = int(param.style);
								}
							}else {
								config.alignSets = [param.align, int(param.style)];
								if (Resource.Status(Target)) {
									AlignSets.addAlignRes(target, config);
								}
							}
							AlignSets.align();
						}else {
							AlignSets.delAlign(target);
						}
					}
					break;
				case 4:
					target = Resource.getObject(Target);
					try {
						if (param[1]) {
							target[param[0]](param[1]);
						}else {
							target[param[0]]();
						}
					}catch (e:*) {
						
					}
					break;
				default:
					break;
				
			}
			
			
		}
		
		
		
	}

}