Verax Posted September 23, 2016 Share Posted September 23, 2016 Hi guys, I was trying to make a group of objects and got the following error: phaser.js:45776 Uncaught TypeError: Cannot read property 'length' of undefined Everything seems to be fine, anyone has a clue why this might be happening? FYI: I'm using Phaser 2.5.0 Thank you for your help. Link to comment Share on other sites More sharing options...
lumoludo Posted September 24, 2016 Share Posted September 24, 2016 You'll likely need to include code for anyone to pick out the specific problem, but the problem looks like you are trying to check the length of an uninitialized variable. Something along the lines of: var myArray; console.log(myArray.length) // <-- myArray is currently undefined It may also be a little more obscure, if the undefined variable is being passed into a function or something. Link to comment Share on other sites More sharing options...
Verax Posted September 26, 2016 Author Share Posted September 26, 2016 Well, I'm just making a group, and there is no loop in my code, it says it's in Phaser's postupdate function which would look like this: postUpdate: function() { if (this.customRender) { this.key.render(); } if (this.components.PhysicsBody) { Phaser.Component.PhysicsBody.postUpdate.call(this); } if (this.components.FixedToCamera) { Phaser.Component.FixedToCamera.postUpdate.call(this); } for (var i = 0; i < this.children.length; i++) { this.children.postUpdate(); } } Link to comment Share on other sites More sharing options...
trojanfoe Posted September 27, 2016 Share Posted September 27, 2016 So is this.children initialized? Link to comment Share on other sites More sharing options...
Recommended Posts