It does not look that bad.
Since you know how many items have to be load, you may engage a counter:
private function handleComplete(e:Event) {
_loadCount++;
if (_loadCount == 2) {
dispatchEvent(new Event(Event.COMPLETE));
}
}
:-)
Am 18.03.2011 02:09, schrieb Mattheis, Erik (MIN-WSW):
I'm building an AIR app following the MVC pattern. Several parts of the model
have to be loaded or created before the view can be initialized. I'm doing it
like this - which works, but seems clunky. Is there a better way? From the main
class of the model:
public function Model() {
_database = new Database();
_database.addEventListener(Event.COMPLETE, handleComplete);
_database.init();
_siteData = new SiteData();
_siteData.addEventListener(Event.COMPLETE, handleComplete);
_siteData.init();
}
private function handleComplete(e:Event) {
if (e.target is SiteData) {
_siteDataLoaded = true;
}
else if (e.target is Database) {
_databaseLoaded = true;
}
if (_siteDataLoaded&& _databaseLoaded) {
dispatchEvent(new Event(Event.COMPLETE));
}
}
_ _ _
Erik Mattheis | Weber Shandwick
P: (952) 346.6610
M: (612) 377.2272
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders