I kind of figured out the issue, but would like to get some confirmation...
The issue at hand was that I was adding the listeners almost at the same
time that the application starts... here is one sample:
-------MAIN.as
package {
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite {
public function Main() {
var mm = new MyMessage;
mm.addEventListener(MyMessage.DONE, theComplete);
}
private function theComplete ( e : Event ) {
trace("THE COMPLETE")
}
}
}
------------------ MYMESSAGE.as
package {
import flash.display.Sprite;
import flash.events.*;
import flash.utils.*;
public class MyMessage extends EventDispatcher {
public static const DONE : String = "complete";
public function MyMessage () {
init();
}
public function init() {
theDispatch();
}
public function theDispatch() {
dispatchEvent( new Event(MyMessage.DONE))
}
}
}
------------
Now if i put a time out, the application is able to register the listeners.
So I must assume there is no way to assign a listener at the same time you
are creating an object. Is that correct?
------
On Mon, May 19, 2008 at 1:07 PM, Helmut Granda <[EMAIL PROTECTED]>
wrote:
> Hi all,
> I have an issue trying to dispatch a simple event. dispatchEvent(new
> Event(ClassName.EVENT_NAME));
>
> for some reason the event is not being triggered -unless- i put a time out
> before it...
>
> like so:
>
> setTimeout(doDispatch, 1);
>
> private function doDispatch () : void {
>
> dispatchEvent(new Event(ClassName.EVENT_NAME));
>
> }
>
> Isn't this weird? Is there any reason why this behavior happens?
>
> TIA
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders