Flash AS3 自定义事件应该在“兄弟”MC 中冒泡

发布于 2024-09-10 21:33:37 字数 504 浏览 2 评论 0原文

这篇博文似乎很旧,但我的问题最适合放在这里。 MC 构造上进行自定义事件调度,

我正在像这样的main_MC/room_MC/button_MC main_MC/room2_MC 的

当接收到 button_MC.MOUSE.CLICK 时,我正在从 room_MC 调度自定义事件。它冒泡到 main_MC ,我可以用它做一些事情。真的很好。

但是:我希望在 room2_MC 中处理分派的事件。有没有办法让它在 room2_MC 中也冒泡?

感谢您的回答。

问候。

迈克


感谢您的回答。你写的结构示例是一样的吗?

好的。冒泡仅朝一个方向进行,但我绝对可以通过将 stage.addEventListener 添加到构造函数来捕获 main_MC/room2_MC 中的事件。

好的。如果我的解决方案有问题,我会尝试你的建议。

再次:感谢您抽出时间来回答。

麦克风

down vote

Hi,

this blogposts seem to be really old, but my question is fitting best in here. I am doing custom event dispatching on a MC construct like this

main_MC/room_MC/button_MC main_MC/room2_MC

I am dispatching a custom event from room_MC when receiving a button_MC.MOUSE.CLICK. It bubbles up to main_MC where I can do something with it. Really nice.

BUT: I want the dispatched event being handled in room2_MC. Is there a way to let it bubble up in room2_MC, too?

Thanks for your answers.

Regards.

Mike


thanks for your answer. The structure-examples you wrote are the same?

Ok. Bubbling goes in one direction only but I can definitely catch the Event in main_MC/room2_MC by adding stage.addEventListener to the constructor.

Ok. If I am somehow wrong with my solution I'll try your suggestion.

Again: Thanks for taking time to answer.

Mike

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

゛清羽墨安 2024-09-17 21:33:37

目前我发现:在 room2_MC 中使用 stage.addEventListener 似乎有效。

但也许有更好的解决方案?

Currently I found out: Using stage.addEventListener in room2_MC seems to work.

But maybe there is a better solution?

爱她像谁 2024-09-17 21:33:37

有点不清楚这是否是这样的一种结构:
main_MC/room_MC/button_MC main_MC/room2_MC
或 2 个这样的:
main_MC/room_MC/button_MC
main_MC/room2_MC

无论哪种方式,答案是否定的,冒泡仅朝一个方向进行,直到对象父对象。

但是,您可以在 main_MC 中捕获事件,然后调用 room2_MC 上的方法,并将事件对象传递给它(如果需要),例如,如果您在自定义事件中存储数据。

华泰

It's a little unclear if this is one structure like this:
main_MC/room_MC/button_MC main_MC/room2_MC
or 2 like this:
main_MC/room_MC/button_MC
main_MC/room2_MC

Either way the answer is no, bubbling only goes in one direction, up to the objects parent.

You can however catch the event in main_MC and then call a method on room2_MC and pass the event object to it if you need to, for example if you're storing data in your custom events.

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文