stopPropagation

You can call either the event's stopPropagation() method or the stopImmediatePropagation() method to prevent an Event object from continuing on its way through the event flow.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init(event)">

<mx:Script>

	<![CDATA[

		import flash.events.MouseEvent;

		import flash.events.Event;

		public function init(e:Event){

		myBtn_1.addEventListener(MouseEvent.CLICK,clickBtn_1);

		myBtn_1.addEventListener(MouseEvent.CLICK,clickBtn_2);

		myBtn_1.addEventListener(MouseEvent.CLICK,clickBtn_3);

		myPanel.addEventListener(MouseEvent.CLICK, clickPanel);

		}

		private function clickBtn_1(evt:Event):void{

		myText.text += "/n/nButton 1 clicked !";

		}

		private function clickBtn_2(evt:Event):void{

		myText.text += "/n/nButton 2 clicked !";

		

		}

		private function clickBtn_3(evt:Event):void{

		myText.text += "/n/nButton 3 clicked !";

		

		}

		public function clickPanel(e:Event) {

		myText.text += "/n Panel clicked !";

		}

	]]>

</mx:Script>

	<mx:Panel x="37" y="51" width="250" height="200" layout="absolute" id="myPanel">

	<mx:Text x="126" y="212" text="Text" width="100" id="myText"/>

	</mx:Panel>

	<mx:Button x="126" y="116" label="Button" id="myBtn_1"/>

</mx:Application>
output:
Button 1 clicked !
Button 2 clicked !
Button 3 clicked !
Panel clicked !
add evt.stopPropagation();on clickBtn_2
output:
Button 1 clicked !
Button 2 clicked !
Button 3 clicked !
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值