I'm currently creating a new application (again) using Corona, and one thing I'm trying to use more from now on, are the event Dispatcher functions attached in the display library.
I started to see how interesting it is to set custom triggers to an displayObject I created, and bind them to buttons using "object:dispatchEvent()".
I'm currently developing a RPG game (or just messing around with code again..), and I'm using these triggers to execute some custom skill function. It's easy to use them this way because I can simply plug or unplug them as pieces of LEGO in the code, making it easier to develop the game.
However, with this API, there is just 2 operations I can use: add and remove:
- As I can see when the application starts, the add function works like inside a stack, adding the elements at the end of the object.
- And the removal operation removes the listener from the object and reorders it, so it doesn't trigger any error.
Here is my Question:
Is there a way to manage or access this "stack of listeners" manually from the script?
I wanted to add a desired listener at the beginning of the stack, instead of adding it in the end (without having to keep track of all listeners added). Or I wanted to reorder it based in some comparison operation..