{"action":"closed","issue":{"url":"https://api.github.com/repos/photonstorm/phaser/issues/1679","labels_url":"https://api.github.com/repos/photonstorm/phaser/issues/1679/labels{/name}","comments_url":"https://api.github.com/repos/photonstorm/phaser/issues/1679/comments","events_url":"https://api.github.com/repos/photonstorm/phaser/issues/1679/events","html_url":"https://github.com/photonstorm/phaser/issues/1679","id":62954730,"number":1679,"title":"Destroying a group with a sprite containing an animation on the onComplete signal causes a JS error.","user":{"login":"trueicecold","id":365152,"avatar_url":"https://avatars.githubusercontent.com/u/365152?v=3","gravatar_id":"","url":"https://api.github.com/users/trueicecold","html_url":"https://github.com/trueicecold","followers_url":"https://api.github.com/users/trueicecold/followers","following_url":"https://api.github.com/users/trueicecold/following{/other_user}","gists_url":"https://api.github.com/users/trueicecold/gists{/gist_id}","starred_url":"https://api.github.com/users/trueicecold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trueicecold/subscriptions","organizations_url":"https://api.github.com/users/trueicecold/orgs","repos_url":"https://api.github.com/users/trueicecold/repos","events_url":"https://api.github.com/users/trueicecold/events{/privacy}","received_events_url":"https://api.github.com/users/trueicecold/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-19T10:59:07Z","updated_at":"2015-03-23T07:56:09Z","closed_at":"2015-03-23T07:56:09Z","body":"Example code:\r\n\r\n```\r\nthis.enemy_sprite = this.group.create(x, y, 'zombie');\r\nthis.enemy_sprite.scale.set(1);\r\nthis.enemy_sprite.scale.x = -1;\r\nthis.enemy_sprite.smoothed = false;\r\nthis.enemy_sprite.anchor.set(0.5, 0.5);\r\n\r\nthis.walk_anim = this.enemy_sprite.animations.add('walk');\r\nthis.walk_anim.onComplete.add(this.destroy, this);\r\nthis.walk_anim.play(10, false);\r\n\r\nthis.destroy = function() {\r\n    this.group.destroy(true);\r\n}\r\n```\r\n\r\ncauses a JS error:\r\n\r\n```\r\nUncaught TypeError: Cannot read property 'getFrame' of null phaser.js:53464 \r\nPhaser.Animation.update phaser.js:53464 \r\nPhaser.AnimationManager.update phaser.js:52802 \r\nPhaser.Sprite.preUpdate phaser.js:37442 \r\nPhaser.Group.preUpdate phaser.js:21860 \r\nPhaser.Group.preUpdate phaser.js:21860 \r\nPhaser.Stage.preUpdate phaser.js:20367 \r\nPhaser.Game.updateLogic phaser.js:26737 \r\nPhaser.Game.update phaser.js:26684 \r\nPhaser.RequestAnimationFrame.updateRAF phaser.js:46614 \r\nPhaser.RequestAnimationFrame.start._onLoop phaser.js:46598 \r\n```\r\n\r\nNote: delaying the \"group destroy\" by using setTimeout seems to fix it, but it's not a proper solution...\r\nMy guess is that the animation keeps running for a couple more frames even when the onComplete signal was sent?\r\n\r\nUsing Phaser 2.2.2"}}