Initializing your app

Depending upon timing in your flex app there is a possibility of your creationComplete=init() method executing and dispatching an event that uses the service layer before the service layer has been initialized. To handle this situation you need to use the MVCServicesInitializedEvent that is thrown by the framework like so:

public function init():void { // set up our MVC controller for this component addEventListener( MVCServicesInitializedEvent.MVC_SERVICES_INITIALIZED, servicesInit); controller = new MyAppController(this); if (getService() != null) { dispatchEvent(new MyAppInitEvent()); } } private function servicesInit(ev:Event):void { dispatchEvent(new MyAppInitEvent()); }

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress