var wgt:IBaseWidget = ViewerContainer.getInstance().widgetManager.getWidget(Number(acWidgets.id),false); wgt.setState(wgtObj.state); if(wgt.getState() != WidgetStates.WIDGET_MINIMIZED) { wgt.initialWidth = wgtObj.width; wgt.initialHeight = wgtObj.height; } wgt.setXYPosition(Number(acWidgets.x),Number(acWidgets.y)); wgt.setPreload(wgt.getState());
wgt = moduleInfo.factory.create() as IBaseWidget;
//This is code for MapManager.mxml //config private function config(event:AppEvent):void { configData = event.data as ConfigData; map = new Map(); map.id = "map"; map.zoomSliderVisible = false; map.addEventListener(MapEvent.LOAD, mapLoadComplete); this.addChild(map); SiteContainer.dispatchEvent(new AppEvent(AppEvent.MAP_LOADED, false, false, map)); var infoContainer:Canvas = new Canvas(); infoContainer.percentWidth = 100; infoContainer.percentHeight = 100; infoContainer.horizontalScrollPolicy = "off"; infoContainer.verticalScrollPolicy = "off"; this.addChild(infoContainer); infoPopup = new InfoPopup(); infoPopup.map = map; infoContainer.addChild(infoPopup); navToolbar = new Navigation(); navToolbar.map = map; drawToolbar = new Draw(); drawToolbar.map = map; drawToolbar.addEventListener(DrawEvent.DRAW_END, onDrawEnd); getDefaultStatus(); var i:int = 0; for (i = 0; i < configData.configExtents.length; i++) { var id:String = configData.configExtents.id; var ext:String = configData.configExtents.extent; var extArray:Array = ext.split(" "); var extent:Extent = new Extent(Number(extArray[0]), Number(extArray[1]), Number(extArray[2]), Number(extArray[3])); if (id == "full") { fullExtent = extent; } if (id == "initial") { map.extent = extent; } } for (i = 0; i < configData.configMap.length; i++) { var label:String = configData.configMap.label; var type:String = configData.configMap.type; var url:String = configData.configMap.url; var visible:Boolean = configData.configMap.visible; var alpha:Number = Number(configData.configMap.alpha); var style:String = configData.configMap.style; switch (type.toLowerCase()) { case "tiled": { var tiledlayer:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer(url); tiledlayer.id = label; tiledlayer.name = label; tiledlayer.visible = visible; tiledlayer.alpha = alpha; map.addLayer(tiledlayer); break; } case "dynamic": { var dynlayer:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(url); dynlayer.id = label; dynlayer.name = label; dynlayer.proxyURL = configData.proxy; dynlayer.visible = visible; dynlayer.alpha = alpha; map.addLayer(dynlayer); break; } case "virtualearth": { var veTiledLayer:VETiledLayer = new VETiledLayer(); veTiledLayer.id = label; veTiledLayer.tokenURL = url; veTiledLayer.environment = "production"; veTiledLayer.visible = visible; veTiledLayer.alpha = alpha; veTiledLayer.mapStyle = style; veTiledLayer.name = label; map.addLayer(veTiledLayer); break; } } } map.panArrowsVisible = false; map.zoomSliderVisible = true; map.logoVisible = true; Alert.show("Do you want to load your last session state? This will restore the maps extent " + "and the visiblity of the layers that were set in your last session." + "Do you want to load your previous session settings?", "Question", Alert.YES|Alert.NO, null, alertClickHandler, expClass, Alert.YES); } private function alertClickHandler(event:CloseEvent):void { if (event.detail==Alert.YES) { //This is where we are loading the state from the saved object settingsSO = SharedObject.getLocal("MYSFV13SAVEDSETTINGS"); if (settingsSO.size > 0) { callLater(setExt,[settingsSO.data.extent]); function setExt(obj:Object):void { var mext:Extent = new Extent(obj.xmin, obj.ymin, obj.xmax,obj.ymax,map.spatialReference); map.extent = mext; } var acVisLayers:ArrayCollection = settingsSO.data.vislayers as ArrayCollection; MapUtil.forEachMapLayer(map, function(layer:Layer):void { var cLayId:int = 0; for(var i:Number=0; i<acVisLayers.length -1;i++) { if(acVisLayers.name == layer.name) { cLayId = i; break; } } var layVisAc:ArrayCollection; if (layer is ArcGISDynamicMapServiceLayer) { layer.visible = acVisLayers[cLayId].visible; ArcGISDynamicMapServiceLayer(layer).visibleLayers = acVisLayers[cLayId].visarray; } else if (layer is ArcIMSMapServiceLayer) { layer.visible = acVisLayers[cLayId].visible; ArcIMSMapServiceLayer(layer).visibleLayers = acVisLayers[cLayId].visarray; } else if (layer is ArcGISTiledMapServiceLayer) { layer.visible = acVisLayers[cLayId].visible; } }); } }
Daniel, I tested this again and low and behold it was not working, so I dug in and guess there is some syntax errors in the JavaScript portion so try replacing your index.template.html with this:<!-- saved from url=(0014)about:internet --> <html lang="en"> <!-- Smart developers always View Source. This application was built using Adobe Flex, an open source framework for building rich Internet applications that get delivered via the Flash Player or to desktops via Adobe AIR. Learn more about Flex at http://flex.org // --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>${title}</title> <script src="AC_OETags.js" language="javascript"></script> <style> body { margin: 0px; overflow:hidden } </style> </head> <body scroll='no'> <script language="JavaScript" type="text/javascript"> <!-- AC_FL_RunContent( "src", "${swf}", "width", "${width}", "height", "${height}", "align", "middle", "id", "${application}", "quality", "high", "bgcolor", "${bgcolor}", "name", "${application}", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", "pluginspage", "http://www.adobe.com/go/getflashplayer" ); // --> </script> <script language="JavaScript" type="text/javascript"> window.onbeforeunload = clean_up; function clean_up() { var flex = document.${application} || window.${application}; flex.savesettings(); } </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="${application}" width="${width}" height="${height}" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> <param name="movie" value="${swf}.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="${bgcolor}" /> <param name="allowScriptAccess" value="sameDomain" /> <embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}" width="${width}" height="${height}" name="${application}" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"> </embed> </object> </noscript> </body> </html>
<!-- saved from url=(0014)about:internet --> <html lang="en"> <!-- Smart developers always View Source. This application was built using Adobe Flex, an open source framework for building rich Internet applications that get delivered via the Flash Player or to desktops via Adobe AIR. Learn more about Flex at http://flex.org // --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>${title}</title> <script src="AC_OETags.js" language="javascript"></script> <style> body { margin: 0px; overflow:hidden } </style> </head> <body scroll='no'> <script language="JavaScript" type="text/javascript"> <!-- AC_FL_RunContent( "src", "${swf}", "width", "${width}", "height", "${height}", "align", "middle", "id", "${application}", "quality", "high", "bgcolor", "${bgcolor}", "name", "${application}", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", "pluginspage", "http://www.adobe.com/go/getflashplayer" ); // --> </script> <script language="JavaScript" type="text/javascript"> window.onbeforeunload = clean_up; function clean_up() { var flex = document.${application} || window.${application}; flex.savesettings(); } </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="${application}" width="${width}" height="${height}" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> <param name="movie" value="${swf}.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="${bgcolor}" /> <param name="allowScriptAccess" value="sameDomain" /> <embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}" width="${width}" height="${height}" name="${application}" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"> </embed> </object> </noscript> </body> </html>
Daniel, Yes it is the browser window closing that fires the save code. The below code is triggered from the index.html. So one of the first things to do is look for this line in the index.html that you are putting on the server. As far as which files need to be moved to the server I would think just the index.swf and index.html, but I normally just grab them all.window.onbeforeunload = clean_up;
window.onbeforeunload = clean_up;
<html lang="en"> <!-- //////////////////////////////////////////////////////////////////////////////// // // Copyright © 2008 - 2009 ESRI // // All rights reserved under the copyright laws of the United States. // You may freely redistribute and use this software, with or // without modification, provided you include the original copyright // and use restrictions. See use restrictions in the file: // <install location>/FlexViewer/License.txt // //////////////////////////////////////////////////////////////////////////////// // --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="keywords" content="ESRI, ArcGIS, Flex, Flex SDK, Viewer, GeoWeb"/> <meta name="description" content="Flex Viewer to demonstrate the best practice to develop GeoWeb application by leveraging the power of spatial technologies"/> <meta name="revised" content="version 1.0, Nov 14, 2008" /> <title>Viewer</title> <script src="AC_OETags.js" language="javascript"></script> <style> body { margin: 0px; overflow:hidden } </style> </head> <body scroll='no'> <script language="JavaScript" type="text/javascript"> <!-- AC_FL_RunContent( "src", "index", "width", "100%", "height", "100%", "align", "middle", "id", "index", "quality", "high", "bgcolor", "#6e6e6e", "name", "index", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", "pluginspage", "http://www.adobe.com/go/getflashplayer" ); // --> </script> <!--New JavaScript function for State--> <script language="JavaScript" type="text/javascript"> window.onbeforeunload = clean_up; function clean_up() { var flex = document.${application} || window.${application}; flex.savesettings(); } </SCRIPT> <!--End New JavaScript function for State--> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="index" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> <param name="movie" value="index.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#6e6e6e" /> <param name="allowScriptAccess" value="sameDomain" /> <embed src="index.swf" quality="high" bgcolor="#6e6e6e" width="100%" height="100%" name="index" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"> </embed> </object> </noscript> </body> </html>
alert('hello');
import mx.controls.Alert; Alert.show("Hello");
for(var w:int=0; w<configData.widgetContainers.length; w++) { for(var wig:int=0; wig<configData.widgetContainers.widgets.length; wid++) { var wgt:Object = configData.widgetContainers.widgets[wid]; var preload:String = wgt.preload; var label:String = wgt.label; var icon:String = wgt.icon; var config:String = wgt.config; var url:String = wgt.url; var headless:String = wgt.headless; } }
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.