Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phaser.Group#iterate: Cannot set property '0' of undefined #1352

Closed
tasos-ch opened this issue Nov 22, 2014 · 1 comment
Closed

Phaser.Group#iterate: Cannot set property '0' of undefined #1352

tasos-ch opened this issue Nov 22, 2014 · 1 comment

Comments

@tasos-ch
Copy link

Example

var group = new Phaser.Group();
group.iterate('name', 'test', Phaser.Group.RETURN_NONE, function(item) {})

The above code fails with the message:

Uncaught TypeError: Cannot set property '0' of undefined

The Problem

Line 1468 of the Phaser.Group file is causing the problem. This line reads:

args[0] = this.children[i];

The problem is that the args argument is not initialized anywhere inside the iterate method before that call.

Possible Solutions

For me it would be enough a relevant description of the args parameter to be added in the documentation where it would be mentioned that when a callback is set, then a value for the args parameter should be set as well.

pnstickne added a commit to pnstickne/phaser that referenced this issue Nov 22, 2014
Update iterate documentation to cover usage of `args` and added a guard so
that the callback can be used without requiring that `args` is specified.

Ref. phaserjs#1352
@photonstorm
Copy link
Collaborator

This is now fixed in dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants