actionscript-3 - AS3EnterFrame事件传播理解问题

标签 actionscript-3 events displayobject event-propagation enterframeevent

我无法理解 EnterFrame 事件的传播路径。 我知道事件有 3 个阶段:捕获、AtTarget 和冒泡。

当我查看 flash.events.Event 类时,我发现 Event 没有冒泡。

如果我在任何 DisplayObject 上添加事件监听器,它将接收 Enter 帧事件。 如果我对 useCapture = true 执行相同操作,则不会收到任何事件。

但是不是所有事件都应该经过捕获阶段吗? 如果我检查事件目标,它将返回接收 DisplayObject 作为其目标。

EnterFrame 事件的目标在传播时是否发生更改,或者是否创建了新事件并将其传递给每个 DisplayObject?

Flash 是否为所有 DisplayObject 保留一个单独的列表?因为即使 DisplayObject 没有添加到 Display Tree 中也会收到 EnterFrame 事件?

最佳答案

ENTER_FRAME (from AS3 Reference)

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.

回到你的问题:

If I add an Eventlistener on any DisplayObject it receives the Enter frame event. If I do the same with useCapture = true no Event is received.

useCapture = true//这不会执行任何操作,因为 ENTER_FRAME 没有“捕获阶段”

But shouldn't all Events pass through the capturing phase?

仅限具有“捕获阶段”的事件

If I check the Event target it returns the receiving DisplayObject as its target.

这是正确的

Does the target for the EnterFrame event get changed while propagating or is a new Event created and passed to every DisplayObject?

它被单独发送到每个目标。

Does Flash keep a separated List with all DisplayObjects? Because the EnterFrame event is even received when the DisplayObject is not added to the Display Tree?

这在 Sunil D 评论中得到了回答

关于actionscript-3 - AS3EnterFrame事件传播理解问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16900176/

相关文章:

actionscript-3 - Adobe AIR : touch screen doesn't trigger mouse down event correctly

python - 如何使用 Python 将控制台输出重定向到 pyqt5 qplainTextEdit 小部件?

快速输入字符时的 Javascript 击键陷阱

events - 如何在 Angular 6 中以编程方式触发 'Click' 事件?

JavaScript 使用主题标签更改显示

java - 无法将文本设置到 TextView

php - 在 Godaddy 上将 XML 从 AS3 发送到 PHP

actionscript-3 - 用于监视从显示列表中添加/删除 MovieClips 的事件?

java - 调用未知的构造函数(反射替换)c++

javascript - Key Up 无法使用 JavaScript