rfkrocktk
June 24th, 2009, 06:00 PM
Is there a way to make event flow occur synchronously?
Basically this is my scenario. I have a single method call that gets triggered by a server request. I want to be able to notifiy subscribers that the method has/is executing so that they may return a result. By modifying an attribute of the actual event object, the method can return that result to the server dynamically. Eg:
//method invoked by server
public function whatever(...parameters):* {
var event:MyEvent = new MyEvent(MyEvent.TYPE);
dispatchEvent(event);
return event.returnValue;
}
//subscriber to this event
private function onWhatever(e:MyEvent):void {
e.returnValue = "hellow";
}
This code works around 70% of the time, but sometimes I see things are really happening asynchronously in Flash Player's event flow. Is there anything I can do to regulate this and make sure it happens synchronously?
Basically this is my scenario. I have a single method call that gets triggered by a server request. I want to be able to notifiy subscribers that the method has/is executing so that they may return a result. By modifying an attribute of the actual event object, the method can return that result to the server dynamically. Eg:
//method invoked by server
public function whatever(...parameters):* {
var event:MyEvent = new MyEvent(MyEvent.TYPE);
dispatchEvent(event);
return event.returnValue;
}
//subscriber to this event
private function onWhatever(e:MyEvent):void {
e.returnValue = "hellow";
}
This code works around 70% of the time, but sometimes I see things are really happening asynchronously in Flash Player's event flow. Is there anything I can do to regulate this and make sure it happens synchronously?