AS3 – Dispatch Event Issue

actionscript-3dispatcheventevent handlingflash

I have an Flash AS3 project that loads external SWFs and controls them in different ways. On some of the loaded SWF files, they have a "Next Selection" button that takes you to a new presentation. On my main externally loaded SWF, I have the code:

setTimeout(function() {dispatchEvent(new Event("nextPresentation", false));}, 4000);

Which automatically move to the next selection in the set. This code works exactly the way I want.

In the next loaded SWF, instead of having a timeout, the user goes through the whole thing where at the end of all the timelines there is a button that says next selection. So I added the following code there:

function nextSelectionClick(evt:MouseEvent) {
    trace('here123');
    dispatchEvent(new Event("nextPresentation", false));
} 

For some reason, that event never makes it up to the file that loaded the SWF. I'm sure I'm getting to the click event because I get the trace, but the event never makes it up even though it seems like it should be the exact same behavior as the timeout. What am I missing here? Why would that code behave different from a button click than from a timeout?

Thanks

Best Answer

You're right in that they should be functioning the same, which leaves the giant question of what else is going on in the application. It seems as though though problem is not here, but else where.

I hate to ask a question like this, but are you sure the event is being fired from the root display object? If it is not firing from there you will not hear it externally.

Sorry, but I can't give you much more without seeing more actual code, or knowing more about the situation(s).

Tyler.

Related Topic