kingBook

导航

as3 组件定义

package  kingBook{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.utils.setTimeout;
	
	public class CustomMc extends MovieClip{
		[Inspectable(type="String",defaultValue="who are you?")]
		public var message:String;
		
		[Inspectable(type="List",defaultValue="a",enumeration ="a,b,c,d")]
		public var id:String;
		
		[Inspectable(type="List",defaultValue="-1",enumeration ="-1,1")]
		public var dir:int;
		
		[Inspectable(name = "激活属性", variable = "enabledProperty",type="Boolean",defaultValue=false)]
		public var enabledProperty:Boolean;
		
		public function CustomMc(){
			this.addEventListener(Event.ENTER_FRAME,enterFrame);
		}
		
		private function enterFrame(e:Event):void{
			this.removeEventListener(Event.ENTER_FRAME,enterFrame);
			trace("message:"+message, "id:"+id, "dir:"+dir, "enabledProperty:"+enabledProperty);
			/**
			* 勾选"激活属性",输出:message:who are you? id:a dir:-1 enabledProperty:true
			* 必须改变定义的属性中的任意一项为非默认值,所有的自定义默认值才生效,
			* 否则获取得到的值就是as3各类型的默认值,以上如果不勾选"激活属性"和不改变其它项就
			* 输出:message:null id:null dir:0 enabledProperty:false
			*/

		}

	};
	
}

  

posted on 2015-11-20 10:56  kingBook  阅读(678)  评论(0编辑  收藏  举报