repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 3277904c739c6735555c7d44ae492056dd7d40a0:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 3277904c739c6735555c7d44ae492056dd7d40a0
Author: James Baicoianu 
Date:   Fri Apr 6 13:35:01 2018 -0700

    More robust object start-up

diff --git a/scripts/janusbase.js b/scripts/janusbase.js
index 969fc518f5c82c42d31d1c83150c4b235bae5409..
index ..3f6c78e07e58da470757c6499dd20c347879e137 100644
--- a/scripts/janusbase.js
+++ b/scripts/janusbase.js
@@ -62,11 +62,13 @@ elation.require(['engine.things.generic', 'utils.template'], function() {

       // FIXME - saving references to bound functions, for future use.  This should happen deeper in the component framework
       this.handleFrameUpdates = elation.bind(this, this.handleFrameUpdates);
+      this.created = false;
     }
     this.createChildren = function() {
       if (typeof this.create == 'function') {
         this.create();
       }
+      this.created = true;
     }
     this.updateColor = function() {
       if (this.properties.color === this.defaultcolor) {
@@ -431,7 +433,7 @@ console.log('got collider', collider, collision_id);
       this.resetFrameUpdates();
       this.dispatchEvent({type: 'update', data: ev.data});
       var proxy = this.getProxyObject();
-      if (typeof proxy.update == 'function') {
+      if (typeof proxy.update == 'function' && this.created) {
         proxy.update(ev.data);
       }
     }
@@ -520,7 +522,7 @@ console.log('got collider', collider, collision_id);
         proxyobj = this.room.jsobjects[obj];
       }
       if (proxyobj) {
-        if (proxyobj.parent) {
+        if (proxyobj.parent && typeof proxyobj.parent.removeChild == 'function') {
           proxyobj.parent.removeChild(proxyobj);
         }
         //var realobj = this.room.getObjectFromProxy(proxyobj);
@@ -528,7 +530,9 @@ console.log('got collider', collider, collision_id);
         if (realobj) {
           this.add(realobj);
           this.updateScriptChildren();
-          realobj.start();
+          if (typeof realobj.start == 'function') {
+            realobj.start();
+          }
         }
       }
     }

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