TomBck
TomBck

Reputation: 25

Termination of execution of all events

I feel like this has probably been asked/answered here, and if so, I apologize for the bandwidth, but I don't see any explanation. There are many objects, which respond to different events. Is it possible to do so for a certain time all the objects have ceased to respond to all events, and then all events recovered? Thanks.

Upvotes: 1

Views: 26

Answers (1)

MarPi
MarPi

Reputation: 126

Keep references to objects in the list, for example in the array. In "a certain time" unsubscribe all objects from the event.

 for(var i:int = 0; i < objectsList.length; i++){
 var obj:MyObject = objectsList[i];
 obj.removeEventListener("MY_EVENT", eventHandler);
 }

Get a flag (variable) is responsible for your "a certain time" In the event handler check the flag if it is false execute handler code, if true go of it

    private function eventHandler(e:Event):void{
    if(flag){
            return;
    }
    //handler code....
    }

Upvotes: 1

Related Questions