事件冒泡阻止event.stopPropagation()

2023-12-16 13:08

本文主要是介绍事件冒泡阻止event.stopPropagation(),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

事件冒泡阻止event.stopPropagation()

package
{
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;

    public class EventBubble extends Sprite
    {
        private var msgTxt:TextField;
        public var msg_txt:TextField;
        private var father1:Sprite;
        private var father2:Sprite;
        private var child1:Sprite;
        private var child2:Sprite;

        public function EventBubble()
        {
            this.father1 = new Sprite();
            this.father2 = new Sprite();
            this.child1 = new Sprite();
            this.child2 = new Sprite();
            this.msgTxt = this.getChildByName("msg_txt") as TextField;
            this.father1.graphics.beginFill(6671615);
            this.father1.graphics.drawRect(0, 0, 180, 140);
            this.father1.graphics.endFill();
            this.father1.x = 0;
            this.father1.y = 0;
            addChild(this.father1);
            this.father2.graphics.beginFill(5854273);
            this.father2.graphics.drawRect(0, 0, 180, 140);
            this.father2.graphics.endFill();
            this.father2.x = this.father1.x + this.father1.width + 5;
            this.father2.y = this.father1.y;
            addChild(this.father2);
            this.child1.graphics.beginFill(5854273);
            this.child1.graphics.drawRect(0, 0, 80, 40);
            this.child1.graphics.endFill();
            this.child1.x = 20;
            this.child1.y = 20;
            this.father1.addChild(this.child1);
            this.child2.graphics.beginFill(6671615);
            this.child2.graphics.drawRect(0, 0, 80, 40);
            this.child2.graphics.endFill();
            this.child2.x = 20;
            this.child2.y = 20;
            this.father2.addChild(this.child2);
            this.father1.addEventListener(MouseEvent.CLICK, this.fatherClickHandler);
            this.father2.addEventListener(MouseEvent.CLICK, this.fatherClickHandler);
            this.child1.addEventListener(MouseEvent.CLICK, this.child1ClickHandler);
            this.child2.addEventListener(MouseEvent.CLICK, this.child2ClickHandler);
            return;
        }// end function

        private function fatherClickHandler(event:MouseEvent) : void
        {
            trace("冒了。");
            this.msgTxt.appendText("冒了。\n");
            return;
        }// end function

        private function child1ClickHandler(event:MouseEvent) : void
        {
            trace("冒泡了嗎?");
            this.msgTxt.appendText("冒泡了嗎?\n");
            return;
        }// end function

        private function child2ClickHandler(event:MouseEvent) : void
        {
            event.stopPropagation();
            trace("冒泡了嗎?");
            this.msgTxt.appendText("冒泡了嗎?\n");
            return;
        }// end function

    }
}

posted on 2010-05-19 17:37 jiahuafu 阅读(...) 评论(...) 编辑 收藏

这篇关于事件冒泡阻止event.stopPropagation()的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/500583

相关文章

禁止平板,iPad长按弹出默认菜单事件

通过监控按下抬起时间差来禁止弹出事件,把以下代码写在要禁止的页面的页面加载事件里面即可     var date;document.addEventListener('touchstart', event => {date = new Date().getTime();});document.addEventListener('touchend', event => {if (new

FreeRTOS内部机制学习03(事件组内部机制)

文章目录 事件组使用的场景事件组的核心以及Set事件API做的事情事件组的特殊之处事件组为什么不关闭中断xEventGroupSetBitsFromISR内部是怎么做的? 事件组使用的场景 学校组织秋游,组长在等待: 张三:我到了 李四:我到了 王五:我到了 组长说:好,大家都到齐了,出发! 秋游回来第二天就要提交一篇心得报告,组长在焦急等待:张三、李四、王五谁先写好就交谁的

【经验交流】修复系统事件查看器启动不能时出现的4201错误

方法1,取得『%SystemRoot%\LogFiles』文件夹和『%SystemRoot%\System32\wbem』文件夹的权限(包括这两个文件夹的所有子文件夹的权限),简单点说,就是使你当前的帐户拥有这两个文件夹以及它们的子文件夹的绝对控制权限。这是最简单的方法,不少老外说,这样一弄,倒是解决了问题。不过对我的系统,没用; 方法2,以不带网络的安全模式启动,运行命令行,输入“ne

BT天堂网站挂马事件后续:“大灰狼”远控木马分析及幕后真凶调查

9月初安全团队披露bt天堂网站挂马事件,该网站被利用IE神洞CVE-2014-6332挂马,如果用户没有打补丁或开启安全软件防护,电脑会自动下载执行大灰狼远控木马程序。 鉴于bt天堂电影下载网站访问量巨大,此次挂马事件受害者甚众,安全团队专门针对该木马进行严密监控,并对其幕后真凶进行了深入调查。 一、“大灰狼”的伪装 以下是10月30日一天内大灰狼远控的木马样本截图,可以看到该木马变种数量不

react笔记 8-19 事件对象、获取dom元素、双向绑定

1、事件对象event 通过事件的event对象获取它的dom元素 run=(event)=>{event.target.style="background:yellowgreen" //event的父级为他本身event.target.getAttribute("aid") //这样便获取到了它的自定义属性aid}render() {return (<div><h2>{

react笔记 8-18 事件 方法 定义方法 获取/改变数据 传值

1、定义方法并绑定 class News extends React.Component {constructor(props) {super(props)this.state = {msg:'home组件'}}run(){alert("我是一个run") //方法写在类中}render() {return (<div><h2>{this.state.msg}</h2><button onCli

【Qt】定时器事件

定时器事件 在之前学习QTimer中实现了定时器的功能,而在QTimer背后是QTimerEvent定时器事件进行支撑的。在QObject中提供了一个timeEvent这个函数。 startTimer启动定时器killTimer关闭定时器 Qt 中在进⾏窗⼝程序的处理过程中,经常要周期性的执⾏某些操作,或者制作⼀些动画效果,使⽤定 时器就可以实现。所谓定时器就是在间隔⼀定时间后,去执⾏某⼀

Imageview在百度地图中实现点击事件

1.首先第一步,需要声明的全局有关类的引用 private BMapManager mBMapMan; private MapView mMapView; private MapController mMapController; private RadioGroup radiogroup; private RadioButton normalview; private RadioBu

fetch-event-source 如何通过script全局引入

fetchEventSource源码中导出了两种类型的包cjs和esm。但是有个需求如何在原生是js中通过script标签引呢?需要加上type=module。今天介绍另一种方法 下载源码文件: https://github.com/Azure/fetch-event-source.git 安装: npm install --save-dev webpack webpack-cli ts

myEclipse失去焦点时报错Unhandled event loop exception的解决方案

一句话:百度杀毒惹的祸。。。。果断卸载后问题解决。