-2

I'm working on a project for college. I'm making a Third Person Top Down shooter game, I have almost finished but stuck on one main part of the game, getting the enemy movieclip to be removed from the stage when it's hit by a bullet movieclip.

I've managed to get the bullet to be removed from the stage when it hits the enemy and tried copying the code and manipulating it accordingly to remove the enemy also but it doesn't seem to want to work, it throws out 3 errors:

Enemy.as, Line 14 1120: Access of undefined property bulletList.

bullets = bulletList;

Enemy.as, Line 44 1120: Access of undefined property stageRef.

if (stageRef.contains(this))

Enemy.as, Line 45 1120: Access of undefined property stageRef.

stageRef.removeChild(this);

All the AS3 source files can be downloaded for viewing here.

halfer
  • 19,824
  • 17
  • 99
  • 186
cm125192
  • 5
  • 1
  • 1
  • 6
  • No one is going to dig through your code - please add the relevant lines to your question. – Marty Dec 19 '13 at 23:44
  • I've added the specific lines that's causing the errors under the error code itself. – cm125192 Dec 20 '13 at 00:33
  • it would be most helpful to see these lines in context with the rest of the code. I clicked the link but nothing was there... try adding `_root.` in front of the variables and see if that assists. `if (_root.stageRef.contains(this))` and `_root.stageRef.removeChild(this);` – Phlume Dec 20 '13 at 00:34
  • @Phlume `_root` is an ActionScript 2 property, it does not exist in AS3. – Marty Dec 20 '13 at 00:39
  • ah shoot... yup. loose the underscore... `(root.stageRef.contains(this))` and `root.stageRef.removeChild(this);` – Phlume Dec 20 '13 at 00:41
  • @Phlume, sorry I forgot to make the download public. Also adding `root` hasn't made any difference, it's still throwing up the same errors. Did I mention that the enemies are in an array? I think telling you that might help. – cm125192 Dec 20 '13 at 01:28
  • Would it be better if I just paste my code here? Well, in my question? I just thought putting a download link for them would be better so my question was readable and it didn't make it a mile of scrolling down the page. – cm125192 Dec 20 '13 at 01:30
  • And sorry @MartyWallace, I wasn't expecting anyone to 'dig' through my code, I just thought it would be easier to see what the statements are referring to and what functions it was calling because my if statement for `hitTestObject(this)` calls a function called `removeSelf` which is where the last two errors are. – cm125192 Dec 20 '13 at 01:39
  • another suggestion is rather than adding root add MovieClip(root) in front of those variables. – whodeee Dec 20 '13 at 15:39
  • Thanks thats gotten rid of the last two errors, it's just the one on line 14 now thats throwing the error. – cm125192 Dec 21 '13 at 23:40

1 Answers1

0

The error clearly defines that the variable bulletList and stageRef do not exist or are not reachable at this point in the code. How about checking if you have created these variables before trying to access them.

It also would be helpful if you past your Enemy.as (or at least the relevant method where the error occurs).

Dave Cartwright
  • 358
  • 1
  • 7