Impliment ExternalInterface calls for preventing windowunload when changes need saving
authorAndy Allan <gravitystorm@gmail.com>
Fri, 3 Sep 2010 18:46:03 +0000 (18:46 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Fri, 3 Sep 2010 18:46:03 +0000 (18:46 +0000)
potlatch2.mxml
resources/potlatch2.html

index 6ca393578ccf9e5f44b3ff4f703d84d7aa71b362..4a69acbe498dde828fb19272de377057ead172c6 100755 (executable)
                }
         private function onDataDirty(event:Event):void {
                        saveButton.enabled=true;
+            if (ExternalInterface.available) {
+              ExternalInterface.call("markChanged", false);
+            }
                }
                private function onDataClean(event:Event):void {
                        saveButton.enabled=false;
+            if (ExternalInterface.available) {
+              ExternalInterface.call("markChanged", true);
+            }
                }
                
         private function onImageryLoad(event:Event):void {
index abdf193d8e49d2c830da175747da370dfbb2e298..f4533ca618f8ae9601f79c2fec74e34fb1fa7c96 100644 (file)
                return args;
        }
 
+    var changesaved=true;
+  
+    window.onbeforeunload=function() {
+        if (!changesaved) {
+            return 'You have unsaved changes. You need to press the Save button to save them';
+        }
+    }
+
+    function markChanged(a) { changesaved=a; } /* called from flash */
+
        var args = getArgs();
        var lat;
        var lon;