Assign relations to function keys
[potlatch2.git] / net / systemeD / potlatch2 / FunctionKeyManager.as
index 3020866a7dd75f4ecdc45ee10b2e1013b70dd967..f3ab21500e6517408d0a24f75fa6dbf64507a387 100644 (file)
@@ -26,8 +26,8 @@ package net.systemeD.potlatch2 {
 
                public function FunctionKeyManager() {
                        for (var i:uint=1; i<16; i++) {
-                               if (SharedObject.getLocal("user_state").data['F'+i]) {
-                                       keys[i]=SharedObject.getLocal("user_state").data['F'+i];
+                               if (SharedObject.getLocal("user_state","/").data['F'+i]) {
+                                       keys[i]=SharedObject.getLocal("user_state","/").data['F'+i];
                                }
                        }
                }
@@ -42,9 +42,9 @@ package net.systemeD.potlatch2 {
 
                public function setKey(fkey:uint, code:String, value:String):void {
                        keys[fkey]={ code:code, value:value };
-                       var obj:SharedObject=SharedObject.getLocal("user_state");
+                       var obj:SharedObject=SharedObject.getLocal("user_state","/");
                        obj.setProperty('F'+fkey,{ code:code, value:value });
-                       obj.flush();
+                       try { obj.flush(); } catch (e:Error) { trace("Error: "+e.toString()); }
                        dispatchEvent(new Event("key_changed"));
                }
 
@@ -52,9 +52,9 @@ package net.systemeD.potlatch2 {
                        if (key=='') {
                                var oldKey:String=getKeyFor(code,value);
                                keys[Number(oldKey.substr(1))]=null;
-                               var obj:SharedObject=SharedObject.getLocal("user_state");
+                               var obj:SharedObject=SharedObject.getLocal("user_state","/");
                                obj.setProperty(oldKey,null);
-                               obj.flush();
+                               try { obj.flush(); } catch (e:Error) {}
                        } else {
                                setKey(Number(key.substr(1)),code,value);
                        }
@@ -80,6 +80,5 @@ package net.systemeD.potlatch2 {
                        listeners[keys[fkey].code](keys[fkey].value);
                        return true;
                }
-               
        }
 }