Flex中阻止默认事件的派发

阅读更多

 



	
		
	
	
	
	

 

package com.antiy.components{
	import flash.events.Event;
	
	import mx.controls.Alert;
	import mx.core.EventPriority;
	import mx.core.UIComponent;


	[Event(name='alarm', type='flash.events.Event')]
	public class TestComponent extends UIComponent{
		public function TestComponent(){
			super();
			addEventListener('alarm',alarmHandler,false,EventPriority.DEFAULT_HANDLER);
		}
		
		protected function alarmHandler(event:Event):void{
			if (!event.isDefaultPrevented()){
				Alert.show('默认事件没有被取消!');
			}
		}
		
		public function triggerAlarm():void{
			dispatchEvent(new Event('alarm',false,true));
		}
		
		
	}
}
 

 

 

你可能感兴趣的:(Flex,Event,Adobe)