I am trying to dispatch an event but not sure when I should do it to get the right results. The first event “submitClicked” is in the right spot and works great. However, the second event “dataReady” seems like it might be a problem.
I need it to be dispatched after this.compiledFormData is set.
Does AS3 wait for each line of code in a function to be executed before moving on to the next line?
// --------------------------------------------------------------------
public function submitForm()
{
//dispatch an event
var cEvt:FormRendererEvent = new FormRendererEvent( "submitClicked" );
cEvt.customMessage = "Started Submitting Form Data";
dispatchEvent(cEvt);
this.compiledFormData = JSON.encode(this.compileFormData());
var cEvt:FormRendererEvent = new FormRendererEvent( "dataReady" );
cEvt.customMessage = "Data is ready to be used";
dispatchEvent(cEvt);
}//end function
Yes, in AS3 each line must complete before the next line can run. When you dispatch events though, they will go off and do their own thing. So, your “main” code might complete, meanwhile your dispatched events could still be processing.