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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to