Usually when dispatching a new event from an object the only listener who listens to this event is added to the object itself.
Example in Flash:
var objeto:MovieClip = new MovieClip(); //Cria o objeto
objeto.addEventListener("CONTADOR_10", funcaoOuvinte); //Adiciona um ouvinte ao objeto
var contador:int = 0;
for(var i:int = 0; i <= 10; i++) {
contador++;
trace(contador);
if(contador == 10) {
objeto.dispatchEvent(new Event("CONTADOR_10", false, false)); //Despacha um novo evento chamado "CONTADOR_10";
break;
}
}
function funcaoOuvinte(e:Event):void {
trace("Evento concluído/escutado com sucesso!");
}
In the above example, I add a function that runs only when all my code is ready and dispatched with the event called "CONTADOR_10".
I don’t have much knowledge of this library, but I’ve noticed that it possesses the addEventListener
, responsible for adding event listener to the object CairngormEventDispatcher.getInstance()
.
Try adding your code to the listener function:
CairngormEventDispatcher.getInstance().addEventListener("SEU_EVENTO", function():void {
trace("Evento concluído");
}
Remembering that whenever added a listener and this will no longer be used, one should remove it with the removeEventListener
.
biio really, adding the addeventlistener it waits until it is completed. And what happened was, on the first call, he doesn’t even go into the Istener and he doesn’t do anything, just from the second call. What I did to solve for those who have the same problem is to put my logic that was after the call in the Command result() function. Whoever uses this framework will know where it is. Thanks for the help!
– ziad.ali