I'd like to delay the handling for some captured events in ActionScript until a certain time. Right now, I stick them in an Array when captured and go through it when needed, but this seems inefficient. Is there a better way to do this?
well, to me this seems a clean and efficient way of doing that ... what do you mean by delaying? you mean simply processing them later, or processing them after a given time?
you can always set a timout to the actual processing function in your event handler (using flash.utils.setTimeout), to process the event later ... but that is rather inefficient, since you may have many timeouts dangeling about, that need to be handled by the runtme ...
maybe you could specify your needs a little more ...
edit:
ok, basically, flash player is single threaded ... that is bytecode execution is single threaded ...
and any event, that is dispatched, is processed immediatly, i.e. dispatchEvent(someEvent)
will directly call all registered handlers (thus AS bytecode) ...
now there are events, which actually are generated in the background ... these come either from I/O (network, userinput) or timers (TimerEvents) ... now it may happen, that some of these events actually occur, while bytecode is executed ... this usually happens in a different background thread ... these background threads (e.g. for network communication), pass any events (in the abstract meaning of the word) to the main thread ...
communication between threads usually works with (de)queues, as in this case ... if the main thread is busy executing bytecode, then it will ignore these messages, until it is done (notice: nearly any bytecode execution is always the implicit consequence of an event (be it enter frame, or input, or timer or load operation or whatever)) ... when it is idle, it will look in all queues, until it finds an available message, wrapps the information into an ActionScript Event object, and dispatches it as previously described ...
thus this queueing is a very low level mechanism, that comes from thread-to-thread communication (and appears in many multi-threading scenarios), and is inaccessible to you ...
as said before, your approach is completely valid and totally makes sense ... :)
Store them into Vector instead of Array :p
I think it's all about how you structure your program, maybe you can assign the captured event under the related instance? So that it's all natural to process the captured event with it instead of querying from a global vector