# \[AS3\] Centralized EventListeners

**URL:** <https://forum.kirupa.com/t/as3-centralized-eventlisteners/287426>\
**Category:** flash\
**Created:** [April 30, 2009, 9:16pm UTC](https://forum.kirupa.com/t/as3-centralized-eventlisteners/287426 "2009-04-30T21:16:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valaran](https://avatars.discourse-cdn.com/v4/letter/v/ee59a6/32.png) [@Valaran](https://forum.kirupa.com/u/Valaran)\
**Post date:** [April 30, 2009, 9:16pm UTC](https://forum.kirupa.com/t/as3-centralized-eventlisteners/287426/1 "2009-04-30T21:16:08Z")

</div>

Hi,

Saving you a boring read: \*\*ENTER\_FRAME listener to the stage, update everything else from this loop, OR individual listeners to arbitrary classes? \*\*

Its me again, with my ridiculous questions! I’ll jump straight on the boat, when programming flash games in general, what is the best way to go about handling event listeners, say I have 30 enemies that are supposed to be moving at once, and under these enemies are quite a number of classes, all having quite specific tasks, and all need to be updated through a update/render function, I.E the A.I class would need the render/update function to figure out its next move, while the Pathing class would need to figure out its next path to take, and the graphics engine would have to draw the enemies moving… You get the drill.

What is best practice regarding events in such a case? While the A.I update should probably run on a enter\_frame basis the actual moving could be limited to when the X/Y values of enemies are changing, but for this case lets say a lot of the classes needs to be run on a ENTER\_FRAME basis, would it be best to register one ENTER\_FRAME event to the stage, and update everything from within that loop, or registering individual ENTER\_FRAME events to the concerned classes? (Naturally this means proper removal of the listeners after they’ve served their purpose). Also, please concider the X/Y value thing above, would that save any effort, or should I just apply an ENTER\_FRAME listener to this aswell?

Thanks for reading
