事件是所有交互式应用的基础,人机对话需要通过事件机制来完成,Flex应用程序能够为用户提供绝佳的使用体验,就必须要有完善的事件机制作为各种交互的基础。Flex事件机制遵守W3C标准--Document Object Model(DOM) Level 3 Events Specification Version 1.0,具体请参考:
1.事件响应过程 和其他语言时间处理机制不同,除了应用传统监听者设计模式来注册事件的监听外,Flex事件还分为三阶段--Capturing、Targeting、Bubbling,来应对更复杂场景的事件响应需求,根据Flex官方文档,对于三者的描述分别为: About the capturing phase The first part of the event flow is called the capturing phase. This phase comprises all of the nodes from the root node to the parent of the target node. During this phase, Flash Player examines each node, starting with the root, to see if it has a listener registered to handle the event. If it does, Flash Player sets the appropriate values of the Event object and then calls that listener. Flash Player stops after it reaches the target node's parent and calls any listeners registered on the parent. About the targeting phase The second part of the event flow, the targeting phase, consists solely of the target node. Flash Player sets the appropriate values on the Event object, checks the target node for registered event listeners, and then calls those listeners. About the bubbling phase The third part of the event flow, the bubbling phase, comprises all of the nodes from the target node's parent to the root node. Starting with the target node's parent, Flash Player sets the appropriate values on the Event object and then calls event listeners on each of these nodes. Flash Player stops after calling any listeners on the root node.用文档中的插图来描述整个过程:![](https://images0.cnblogs.com/blog/485345/201306/01092257-70cffe06a6c14afa97794ee26a8caaee.gif)