flex事件——父类捕获子类的事件

流程  父类构造---》子类构造————子类抛出事件——》父类捕获
package childEvent
{
	import flash.events.Event;
	
	import mx.controls.Alert;
	import mx.core.UIComponent;
	
	public class Parent extends UIComponent
	{
		public function Parent()
		{
			Alert.show("父类构造");
			this.addEventListener("parentListener",parentListener);
		}
		private function parentListener(e:Event){
			mx.controls.Alert.show("子类抛出事件父类捕获");
		}

	}
}

 

package childEvent
{
	import flash.events.Event;
	
	import mx.controls.Alert;
	
	public class SubClass extends Parent
	{
		public function SubClass()
		{
			super();
			mx.controls.Alert.show("子类构造")
			this.dispatchEvent(new Event("parentListener"));
		}

	}
}

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:childEvent="childEvent.*">
	<childEvent:SubClass>
		
	</childEvent:SubClass>
</mx:Application>

 

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