EXIT_FRAME 冒泡吗?
根据 Flash 文档:
http:// help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/Event.html#
Event.EXIT_FRAME 常量定义 an 的类型属性的值 exitFrame 事件对象。
注意:此活动没有 “捕获阶段”也不是“气泡阶段”, 这意味着事件侦听器必须 直接添加到任何潜在的 目标,目标是否在 是否显示列表。
但是,当在子 DisplayObject 上调用 gotoAndStop 时,会在其容器上引发 EXIT_FRAME 事件,并且似乎无法阻止它。
例如:
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
c = new Circle2();
addChild(c);
this.addEventListener(Event.ENTER_FRAME, enterFrame);
this.addEventListener(Event.EXIT_FRAME, exitFrame);
}
private function enterFrame(e:Event):void
{
trace("enter frame");
c.setPercent(5); // this calls gotoAndStop()
}
private function exitFrame(e:Event):void
{
trace("exit frame");
}
输出为:
输入框架
退出框架
退出框架
在 Circle2 构造函数中我尝试过这个
this.addEventListener( Event.EXIT_FRAME, function(e:Event):void
{
e.stopPropagation();
});
According to the Flash docs:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/Event.html#
The Event.EXIT_FRAME constant defines
the value of the type property of an
exitFrame event object.Note: This event has neither a
"capture phase" nor a "bubble phase",
which means that event listeners must
be added directly to any potential
targets, whether the target is on the
display list or not.
However when calling gotoAndStop on a child DisplayObject the EXIT_FRAME event is raised on it's container and there appears to be no way to stop it.
For example:
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
c = new Circle2();
addChild(c);
this.addEventListener(Event.ENTER_FRAME, enterFrame);
this.addEventListener(Event.EXIT_FRAME, exitFrame);
}
private function enterFrame(e:Event):void
{
trace("enter frame");
c.setPercent(5); // this calls gotoAndStop()
}
private function exitFrame(e:Event):void
{
trace("exit frame");
}
Output is:
enter frame
exit frame
exit frame
In Circle2 constructor I've tried this
this.addEventListener( Event.EXIT_FRAME, function(e:Event):void
{
e.stopPropagation();
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用捕获阶段 然后调用 stopPropagation 进去。
请注意 addEventListener 末尾的 true。
You can try to use capture phase and then call stopPropagation into it.
Note the true at the end of the addEventListener.