Why is the listener worried
Answers
Answered by
1
Yes it will affect your game, primarily because you will need to control all 300 so that they won't create memory leaks in form of defunct (released) objects left in memory because they have a listener attached to say stage. Secondary aspect is performance, each listener taking actions is several function calls below the curtains, thus it's better to organize those listeners somehow. It's fine to have a button listen on itself for say MouseEvent.CLICK and to have 300 buttons like that, because each time you click only a few (ideally one) listeners would react. It's not as fine to have 300 listeners listen for Event.ENTER_FRAMEbecause each frame all of them would be invoked, and it's better to have one listener instead, but every subsystem or every object would then get called from that listener. This approach will also lessen the overhead on Flash event subsystem to direct calls, and lessen your hassle about unattached listeners.
There may be more performance aspects regarding listeners, especially since Flash engine developers started placing security checks into the engine, slowing event processing by a significant margin, these are however obscure and the only thing is known about them is "use fewer listeners". You will still have to rely on Flash event cycle at least on the top level, even if you devise an event processing system of your own, or use a system made by another, but the main point stands, "the fewer, the better". If you can lessen the number of listeners, please do so.
There may be more performance aspects regarding listeners, especially since Flash engine developers started placing security checks into the engine, slowing event processing by a significant margin, these are however obscure and the only thing is known about them is "use fewer listeners". You will still have to rely on Flash event cycle at least on the top level, even if you devise an event processing system of your own, or use a system made by another, but the main point stands, "the fewer, the better". If you can lessen the number of listeners, please do so.
Similar questions