var widgetIdxUnLoadArray:Array = [6,7,8]; private var closeMultiple:Boolean = false; protected function button2_clickHandler(event:MouseEvent):void { closeMultiple = true; preUnloadNextWidget(); } private function preUnloadNextWidget():void { if (widgetIdxUnLoadArray.length > 0) { var id:Number = widgetIdxUnLoadArray[0]; widgetIdxUnLoadArray.splice(0, 1); ViewerContainer.dispatchEvent(new AppEvent(AppEvent.WIDGET_STOP, id)); } } private function myWidgetRemovedHandler(event:AppEvent):void { if (closeMultiple) { closeMultiple=false; preUnloadNextWidget(); } }
<s:Group id="widgetContainer" width="100%" height="100%" left="{_left}" left.collapsedRight="{containerWidth}" left.resized="{_left}" right="{_right}" right.normal="{_right}" right.resized="{_right}" top="{_top}" top.collapsedDown="{containerHeight}" top.resized="{_top}" bottom="{_bottom}" bottom.resized="{_bottom}" clipAndEnableScrolling="true" elementAdd="widgetAddedHandler(event)" elementRemove="widgetRemoveHandler(event)" />
protected function widgetRemoveHandler(event:ElementExistenceEvent):void { var wObj:IVisualElement = event.element; ViewerContainer.dispatchEvent(new AppEvent(AppEvent.WIDGET_REMOVED, wObj)); }
public static const WIDGET_REMOVED:String = "widgetRemoved"; public static const WIDGET_STOP:String = "widgetStopRequested";
ViewerContainer.addEventListener(AppEvent.WIDGET_STOP, onStopWidget);
private function onStopWidget(event:AppEvent):void { var id:Number = event.data as Number; var idx:Object = configData.widgetIndex[id]; var wgtContainer:IWidgetContainer = configData.widgetContainers[idx.container].container.obj; var wgt:Object = configData.widgetContainers[idx.container].widgets[idx.widget]; widgetAdded = false; var widget:IBaseWidget; if (widgetTable.containsKey(id)) { widget = widgetTable.find(id) as IBaseWidget; widget.setState(BaseWidget.WIDGET_CLOSED); } }
<s:Button label="Open Multiple Widget" click="button1_clickHandler(event)" /> var widgetIdxArray:Array = [6,7,8]; // 6,7,8 are widget Ids. This can be obtained from configData object protected function button1_clickHandler(event:MouseEvent):void { ViewerContainer.addEventListener(AppEvent.WIDGET_ADDED, myWidgetAddedHandler); preloadNextWidget(); } private function preloadNextWidget():void { if (widgetIdxArray.length > 0) { var id:Number = widgetIdxArray[0]; widgetIdxArray.splice(0, 1); ViewerContainer.dispatchEvent(new AppEvent(AppEvent.WIDGET_RUN, id)); } } private function myWidgetAddedHandler(event:AppEvent):void { preloadNextWidget(); }
ViewerContainer.dispatchEvent(new AppEvent(AppEvent.WIDGET_CHANGE_STATE, {id: this.widgetId, state:WidgetStates.WIDGET_CLOSED}));
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.