事件优先级总结
package event{import flash.events.Event;import spark.components.Button;[Event(name="test", type="flash.events.Event")][Event(name="demo", type="flash.events.Event")]public class EventPriorityButton extends Button{public function EventPriorityButton(){super();this.addEventListener("test", test1);this.addEventListener("test", test2);this.addEventListener("demo", demo2);this.addEventListener("demo", demo1);}private function test1(event:Event):void{trace("EventPriorityButton.test1");}private function test2(event:Event):void{trace("EventPriorityButton.test2");}private function demo1(event:Event):void{trace("EventPriorityButton.demo1");}private function demo2(event:Event):void{trace("EventPriorityButton.demo2");}}}
<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:event="event.*" creationComplete="eventPriorityTestApp_creationCompleteHandler(event)"><fx:Script><![CDATA[import mx.events.FlexEvent;protected function eventPriorityTestApp_creationCompleteHandler(event:FlexEvent):void{eventPriorityTestButton.addEventListener("test", test3);eventPriorityTestButton.addEventListener("test", test4, false, 20000);eventPriorityTestButton.addEventListener("demo", demo3);eventPriorityTestButton.addEventListener("demo", demo4, false, 10000);}protected function eventPriorityTestButton_clickHandler(event:MouseEvent):void{eventPriorityTestButton.dispatchEvent(new Event("demo"));eventPriorityTestButton.dispatchEvent(new Event("test"));}protected function test3(event:Event):void{trace("EventPriorityApp.test3");}protected function test4(event:Event):void{trace("EventPriorityApp.test4");}protected function demo3(event:Event):void{trace("EventPriorityApp.demo3");}protected function demo4(event:Event):void{trace("EventPriorityApp.demo4");}]]></fx:Script><event:EventPriorityButton id="eventPriorityTestButton" label="事件优先级测试" click="eventPriorityTestButton_clickHandler(event)"/></s:Application>