2

I have trouble understanding the path the EnterFrame Event takes for Propagation. I understand that Events have 3 Phases: Capturing, AtTarget und Bubbling.

When I look at the flash.events.Event class I see that Event does not Bubble.

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.

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?

user1090755
  • 517
  • 1
  • 4
  • 14
  • 2
    This is interesting. The ENTER_FRAME event seems to behave differently than others. 1) As you mentioned it doesn't go through the capture phase, 2) If I add the enter frame listeners to multiple objects it seems like each object receives it's own enter frame event (in the debugger each event has a different memory address, 3) Also it seems that the enter frame event is re-used (same memory address keeps showing up in debugger). As you can imagine this event happens so frequently, the behavior we are seeing might be an optimization by the Flash Player. – Sunil D. Jun 03 '13 at 18:59
  • 2
    At the bottom of this [page on senocular.com](http://www.senocular.com/flash/tutorials/orderofoperations/) they talk about "broadcast events" (events that go to more than one object). I've never heard this term before with respect to events in Flash. I would imagine that broadcast events behave differently (as noted in your question/my comments) than the usual capture -> target -> bubble paradigm that we're all used to. Wish I still had my [Collin Moock](http://shop.oreilly.com/product/9781565928527.do) book... – Sunil D. Jun 03 '13 at 19:16
  • @Sunil D. There is some really nice info in your link. – sanchez Jun 03 '13 at 22:17

1 Answers1

2

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.

So back to your question(s):

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 // this will not do anything, as ENTER_FRAME has no a "capture phase"

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

Only events which have "capture phase"

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

This is correct

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

It is sent individually to each target.

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?

This is answered in Sunil D comment

sanchez
  • 4,519
  • 3
  • 23
  • 53
  • I don't know how I missed that note about the event not having a capture or bubble phase in the documentation after all these years. – Sunil D. Jun 04 '13 at 02:14
  • Wow thank you guys the provided links are really useful. Interesting that some Events behave differently. – user1090755 Jun 04 '13 at 21:07