repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 0134037187549da725cfdb61cf97c996c04138f8:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 0134037187549da725cfdb61cf97c996c04138f8
Author: James Baicoianu 
Date:   Thu Sep 29 03:08:27 2016 -0700

    Allow sound properties to be updated from scripts

diff --git a/scripts/sound.js b/scripts/sound.js
index a7a74585097b453f1f1537d67adcc13d158efcad..
index ..b0d688269827167b8eb98a5764bb21e0e350fd35 100644
--- a/scripts/sound.js
+++ b/scripts/sound.js
@@ -9,8 +9,8 @@ elation.require(['janusweb.janusbase'], function() {
         auto_play: { type: 'boolean', default: false },
         play_once: { type: 'boolean', default: false },
         dist: { type: 'float', default: 1.0 },
-        pitch: { type: 'float', default: 1.0 },
-        gain: { type: 'float', default: 1.0 }
+        pitch: { type: 'float', default: 1.0, set: this.updateSound },
+        gain: { type: 'float', default: 1.0, set: this.updateSound }
       });
       Object.defineProperty(this, 'playing', { get: function() { if (this.audio) return this.audio.isPlaying; return false; } });
     }
@@ -83,5 +83,18 @@ elation.require(['janusweb.janusbase'], function() {
         this.audio.stop();
       }
     }
+    this.updateSound = function() {
+      if (this.audio) {
+        this.play();
+        this.audio.setVolume(this.gain);
+      }
+    }
+    this.getProxyObject = function() {
+      var proxy = elation.engine.things.janussound.extendclass.getProxyObject.call(this);
+      proxy._proxydefs = {
+        gain:         [ 'property', 'gain'],
+      };
+      return proxy;
+    }
   }, elation.engine.things.janusbase);
 });

-----END OF PAGE-----