Waiting for events in flash
Friday, August 24th, 2007You really have to wait for them!
Right - when you load XML for example in something like a repository object and then you want to get at what it may have loaded up such as an array of objects you need to wait until it has actually loaded!
To do this add a public function in the Repository class called onLoad:
public var onLoad:Function = function(){};
And then pass true or false or whatever to this function when done:
repository.onLoad(true);
or if not
repository.onLoad(false);
When using this repository we can now get at this by:
_demoRepository = demoRepository;
var demo:Demo = this;
_demoRepository.onLoad = function() {
//do something now we know it has loaded!
}
In this case we may want to call something on the object calling the repository so we create an instance of itself and that reference will be pulled in.