//MainMenuMediator override public function onRegister():void { //super.onRegister(); _loadMap(); _latLonArray = new ArrayList(); _markerIdentificationArray = new Array(); // // view add listeners // view.list.addEventListener(IndexChangeEvent.CHANGE, _onList_changeHandler); view.exitButton.addEventListener(MouseEvent.CLICK, _onExitButton_clickHandler); //eventDispatcher.addEventListener(ModelUpdateEvent.POPULATE_ON_MAP,_onModelUpdateEventSucess); //eventDispatcher.addEventListener(MappingEvent.POPULATE_ADDRESS_ON_MAP,_onMappingEventSucess); //eventMap.mapListener(eventDispatcher,MappingEvent.POPULATE_ADDRESS_ON_MAP,_onMappingEventSucess,MappingEvent); eventMap.mapListener(eventDispatcher,ModelUpdateEvent.POPULATE_ON_MAP,_onModelUpdateEventSucess,ModelUpdateEvent); // // system add listeners // trace("latitude: "+ stateModel.latitude+ " - longitude: " + stateModel.longitude) // // set view // _setView(); } private function _loadMap():void { _addressMap = new Map(); _addressMap.key = MapUtils.MAP_KEY; _addressMap.url = MapUtils.MAP_URL; _addressMap.sensor="false"; _addressMap.addEventListener(MapEvent.MAP_READY, _addressMap_mapReady); _addressMap.setSize(new Point(view.mapContainer.width, view.mapContainer.height)); view.mapContainer.addElement(_addressMap); _addressMap.addControl(new ZoomControl()); _addressMap.addControl(new MapTypeControl()); //trace("loadingmap.."+MapUtils.MAP_KEY); } //model public function addressInRadius(addressDataList:ArrayList ):void { _addressList = addressDataList; _radius = Number(ObjectUtil.toString(addressDataList.getItemAt(0).radius)); var obj:Object = new Object(); obj.radius= _radius; dispatch(new ModelUpdateEvent(ModelUpdateEvent.POPULATE_ON_MAP,obj)); } //event public class ModelUpdateEvent extends Event { //online monitor public static const ONLINE_STATUS_CHANGE:String = "onlineStatusChange"; //location monitor public static const LOCATION_CHANGE:String = "locationChange"; public static const LOCATION_STATUS_CHANGE:String = "locationStatusChange"; public static const POPULATE_ADDRESSES_ON_MAP:String = "markAddressOnMap"; //user public static const SELECTED_USER_CHANGE:String = "selectedUserChange"; public static const SELECTED_USER_LOADING_CHANGE:String = "selectedUserLoadingChange"; public static const UPDATE_MOBILE_TERMS_AND_CONDITIONS_CHANGE:String = "updateMobileTermsAndConditionsChange"; public static const LOGIN_COMPLETE:String = "loginComplete"; //properties private var _value:Object; public function get value():Object { return _value; } public function ModelUpdateEvent(type:String, value:Object, bubbles:Boolean=true, cancelable:Boolean=false) { super(type, bubbles, cancelable); _value = value; } override public function clone():Event { return new ModelUpdateEvent(type,value); } //BaseContext public class BaseContext extends Context { public function VisiauditBaseContext(contextView:DisplayObjectContainer=null, autoStartup:Boolean=true) { super(contextView, autoStartup); } override public function startup():void { super.startup(); _required(); _stateFeature(); _locationFeature(); _onlineFeature(); _userFeature(); } private function _required():void { //services injector.mapSingleton( DatabaseConnection ); //models //event/command commandMap.mapEvent(RequestDataEvent.GET_APP_VERSION, GetAppVersionCommand, RequestDataEvent); commandMap.mapEvent(ServiceResponseEvent.CURRENT_APP_VERSION_RESULT, GetAppVersionCompleteCommand, ServiceResponseEvent); } private function _stateFeature():void { //services injector.mapSingleton( PropertiesDatabase ); //models injector.mapSingleton( ApplicationStateModel ); //event/command } private function _locationFeature():void { //services injector.mapSingleton( GeolocationService ); injector.mapSingleton(GetStoresListService); //models //event/command commandMap.mapEvent(SetDataEvent.START_POLLING_FOR_LOCATION, StartPollingForLocationCommand, SetDataEvent); commandMap.mapEvent(SetDataEvent.STOP_POLLING_FOR_LOCATION, StopPollingForLocationCommand, SetDataEvent); commandMap.mapEvent(ServiceResponseEvent.LOCATION_RESULT, LocationStatusResponseCommand, ServiceResponseEvent); commandMap.mapEvent(ServiceResponseEvent.GEOLOCATION_STATUS_RESULT, GeolocationStatusResultCommand, ServiceResponseEvent); } private function _onlineFeature():void { //services injector.mapSingleton( OnlineMonitorService ); //models //event/command commandMap.mapEvent(SetDataEvent.START_POLLING_FOR_ONLINE_STATUS, StartPollingForOnlineStatusCommand, SetDataEvent); commandMap.mapEvent(SetDataEvent.STOP_POLLING_FOR_ONLINE_STATUS, StopPollingForOnlineStatusCommand, SetDataEvent); commandMap.mapEvent(ServiceResponseEvent.ONLINE_STATUS_RESULT, OnlineStatusResponseCommand, ServiceResponseEvent); //commandMap.mapEvent(MappingEvent.POPULATE_ADDRESS_ON_MAP,LocationSelectedCommand,MappingEvent); } private function _userFeature():void { //services injector.mapSingleton( UserDatabase ); //models injector.mapSingleton( UserModel ); //event/command injector.mapSingleton( VisiauditService ); commandMap.mapEvent(SetDataEvent.LOGIN_USER, LoginCommand, SetDataEvent); commandMap.mapEvent(ServiceResponseEvent.LOGIN_RESULT, LoginCompleteCommand, ServiceResponseEvent); } } //ChildContext extends BaseContext public class Context extends BaseContext { public function ChildContext(contextView:DisplayObjectContainer=null, autoStartup:Boolean=true) { super(contextView, autoStartup); } override public function startup():void { super.startup(); _commandMaps(); _viewMediatorMaps(); dispatchEvent(new ContextEvent(ContextEvent.STARTUP_COMPLETE, contextView)); } private function _commandMaps():void { commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, StartupCommand, ContextEvent); } private function _viewMediatorMaps():void { //main mediatorMap.mapView(visiaudit, ApplicationMediator); mediatorMap.mapView(LoginView, LoginMediator); mediatorMap.mapView(MainMenuView, MainMenuMediator); mediatorMap.mapView(StoreInformationView,StoreInformationMediator); //utils mediatorMap.mapView(TurnOnGeolocationView, TurnOnGeolocationMediator); mediatorMap.mapView(ConfirmExitView, ConfirmExitMediator); } }