views:

649

answers:

1

Hi,

I am building a framework for loading minigames (in swf), and am running into a problem.

I currently have a listener that listens for events that the child minigame sends to the parent framework. However, if the child sends two messages (events) too close to each other, it seems that the first event simply get ignored, which causes some of the messages not to reach the parent framework at all.

I read that you can queue up actionscript events somehow, so that events are processed in a FIFO basis. How can I do that? Documentation seems to be pretty scarce for this issue, so I am stumped.

Many thanks!

A: 

You should really post code with questions like this; the others are right -- it does sound like you've made a mistake somewhere, and it's a lot easier to help with these kinds of problems when they're accompanied by some code.

That said, even if you dispatched your events in a tight loop, like this:

addEventListener("foo", handleFoo, false, 0);

for (var i:int = 0; i < 100; i++)
{
   dispatchEvent(new FlexEvent("foo"));
}

private function handleFoo(event:Event):void
{
   trace("hello");
}

... you'd see as many "hellos" as iterations of that loop; it doesn't get much "closer together" than that. You can prioritize event handling -- e.g., this listener gets called first (hence the "0" above), this other listener gets called second ("1"), and so on -- using the priority argument of the addEventListener function (again, see above), but that's about it. There's no built-in queueing of event dispatching unless you write the queue yourself.

Christian Nunciato