flex事件处理(三个阶段)
2008-03-26 14:55
316 查看
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
<mx:Script>
<![CDATA[
import flash.events.MouseEvent;
internal function initApp(){
/*
addEventListener(type:String ,listener:Function,useCapture:Boolean=false,priority:int=0,useWeakReference:Boolean=false)
useCapture 表示是否打开捕获事件,默认为false
priority 表示监听器的优先级,默认为0
useWeakReference 表示是否使用弱引用,默认为false
*/
canvas1.addEventListener(MouseEvent.CLICK,pressBtn,true);
canvas2.addEventListener(MouseEvent.CLICK,pressBtn);
btn1.addEventListener(MouseEvent.CLICK,pressBtn);
btn2.addEventListener(MouseEvent.CLICK,pressBtn,true);
}
internal function output(msg:String):void{
txtArea1.text += msg+" ";
}
internal function pressBtn(event:MouseEvent):void{
this.output("是否冒泡---"+event.bubbles);//event.bubbles 表示是否打开冒泡功能
//输出当前的点击对象和事件流当前的阶段,1表示捕获阶段,2表示目标阶段,3表示冒泡阶段
this.output("目标对象:"+event.target+":"+event.eventPhase);
//输出当前正在处理的对象
this.output("遍历对象:"+event.currentTarget);
this.output("------------");
}
]]>
</mx:Script>
<mx:Canvas x="10" y="10" width="328" height="355" id="canvas1">
<mx:Text x="21" y="10" text="canvas1" id="txt1"/>
<mx:Canvas x="10" y="36" width="308" height="135" id="canvas2">
<mx:Text x="129" y="10" text="canvas2" id="txt2"/>
<mx:Button x="118" y="55" label="Button2" id="btn2"/>
</mx:Canvas>
<mx:Button x="21" y="179" label="Button1" id="btn1"/>
<mx:TextArea x="10" y="209" width="308" height="136" id="txtArea1"/>
</mx:Canvas>
</mx:Application>
相关文章推荐
- DOM事件处理有三个阶段
- AS3中Event的target和currentTarget的区别(事件处理的三个阶段)
- 事件处理基础知识(一)捕获、目标、冒泡三个阶段
- FLEX接收回车处理事件
- flex:处理事件
- JSP引擎处理JSP文件请求的三个阶段
- 事件的三个阶段:捕获阶段 目标阶段 冒泡阶段
- 事件的三个阶段:捕获阶段 目标阶段 冒泡阶段
- 【Flex基础】——timer用法及其相关的事件处理(Timer和TimerComplete事件)
- Flex、Java、C#、JavaFX的事件处理机制的比较
- 事件传播的三个阶段
- DOM标准事件的三个阶段:冒泡、捕获 dom事件三个阶段
- 关于FLEX事件堆积 导致处理操作叠加 问题
- 捕获阶段调用事件处理程序和冒泡阶段调用事件处理程序的区别是什么呢?
- 事件的三个阶段
- flex_(8)事件处理_闹钟示例;
- 在flash/flex程序中处理javascript的事件
- Flex事件处理机制
- Flex、Java、C#、JavaFX的事件处理机制的比较
- 事件的三个阶段:捕获阶段 目标阶段 冒泡阶段