加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex3学习轨迹:让Alert对话框不可拖动

发布时间:2020-12-15 05:14:23 所属栏目:百科 来源:网络整理
导读:闲话不说,直接上代码! ?xml version="1.0" encoding="utf-8"?mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" fontSize="12" mx:Script![CDATA[import mx.controls.Alert;private function undraggableAlert():void{var aler

闲话不说,直接上代码!
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" fontSize="12" >
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			private function undraggableAlert():void
			{
				var alert:Alert = Alert.show("不能拖动Alert!");
				alert.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownDo,true);
			}
			private function mouseDownDo(evt:MouseEvent):void
			{
				evt.stopImmediatePropagation();
			}
		]]>
	</mx:Script>
	<mx:Panel title="Alert不可拖动" width="300" height="200" 
        horizontalAlign="center" paddingTop="30">
        <mx:Button id="btn2" label="不可拖Alert"  height="35" width="140" click="undraggableAlert();"/>
    </mx:Panel>
</mx:Application>
先获取一个Alert对象,然后添加监听事件。当在mouseDown事件是调用 mouseDownDo方法。

方法中设置了use_capture函数为true要求在捕获阶段响应事件,方法中使用stopImmediatePropagation(),该方法防止对当前节点和后续节点中的监听器进行处理,并且该方法立即生效。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读