Flex中自定义组件中的冒泡事件 [英] Bubbling events within custom components in Flex

查看:146
本文介绍了Flex中自定义组件中的冒泡事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Flex mxml应用程序文件的另一个自定义组件中使用了自定义组件。是否可以将事件从内部组件中冒泡到外部组件并处理外部组件中的事件?

解决方案

Event 构造函数默认将 bubbles 参数设置为 false 因此,如 Patrick 提及,当你构造事件时,你需要设置 bubbles true

启用冒泡后,事件将继续在UI树中调度,直到 Event.stopPropagation Event.stopImmediatePropagation 被调用。请记住,冒泡只影响UI组件;即使将 bubbles 参数设置为 true ,自定义类触发的事件也不会冒泡。 b $ b

I am using a custom component within another custom component in a flex mxml application file.Is it possible to bubble events from an inner component to the outer component and handle events in the outer component?

解决方案

The Event constructor defaults the bubbles parameter to false so, as Patrick mentions, you need to set bubbles to true when you construct the event.

Once bubbling is enabled, the event will continue to be dispatched up the UI tree until Event.stopPropagation or Event.stopImmediatePropagation is called.

Keep in mind, though, that bubbling only affects UI components; events fired from custom classes will not bubble, even if the bubbles argument is set to true.

这篇关于Flex中自定义组件中的冒泡事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆