How do I create an event handler to check that a class has
completed its tasks before I continue with my next line of code?
For example, in the code below, the class that is being used must
hit a database before it is able to return a value for myVar.
However, the trace statement executes before the value of myVar has
If you are loading from a database you have a listener
function on the result, something like onResult(event:ResultEvent)
In that listener function you usually parse the data and then
dispatch a (custom) event that the data has loaded. Any object that
needs to know about this event, registers for the event and in a
listener function you can proceed with your code.