Sound not heard for duplicated MCs

Hey guys, here’s the deal.

I’m working on my first side scrolling shoot 'em up arcade style game (don’t you just love these types of threads…) and it’s going along quite well actually. Just got a few little issues. Don’t have much experience with flash methods and such.

B4 I posted this, I searched the forums and the internet and couldn’t find the answer and am just kinda tired of trying to figure this out (at least for now…)

BTW, I’m using what’s below for duplicating the enemy MC:

numEnemy = 3;
for (i=2; i<=numEnemy; i++) {
enemy1.duplicateMovieClip(“enemy”+i, i+1000);
// trace to see output. See below.
// trace(i);
}
The game works fine with the first enemy, but the other 2 that are duplicated aren’t affected in the same way. For example, when the bullet hits the other 2 enemies,

Good----

  1. all explode (an explodeMC) the same way,
  2. they all add points to my score the same way,
  3. take away health from my health score if hit by the enemy

but they don’t

Bad----

  1. make the explosion sound when they hit 2 of the 2 MC duplicates.

So basically, if you shoot all three enemies coming at you, all three explode and add points to your score, and if the enemies hit you, it takes points away from your health, BUT when they explode, only 1 of the 3 enemies make the exploding sound.

Here’s the method I’m using in terms of the sound objects. Within the explode MC, I put:

onClipEvent (load) {
popexplode = new Sound(explodeMC);
popexplode.attachSound(“popexplode01”);
popexplodeVolume = 100;
popexplode.setVolume(popexplodeVolume);
// The exact path in which the sound object is defined
// must be spelled out.
// This explosion sound is attached inside the explodeMC, which is inside
// the enemy1MC
// Therefore, see below:
_root.enemy1.explodeMC.popexplode.start(0, 1);
_root.enemy1.explodeMC.popexplode.setVolume(popexplodeVolume);
}

I’m pretty sure this has something to do with the path to the sound object being a little off (see above) b/c I think that I’m directing it to the original enemy (enemy1) instead of the duplicates… or something like that. Why? B/c, for example, for the hitTest, if I use:

if (_root.enemy1.hitTest(_root.player._x, _root.player._y, true)) {
_root.health = _root.health-1;…

it gives the same problem of only one of the duplicated enemies hurting my health score

but if I use:

if (this.hitTest(_root.player._x, _root.player._y, true)) {
_root.health = _root.health-1;…

it corrects the problem and all enemy duplicates hurt my health score, so I figure that I’m close to solving the problem with the sound…

I’m sure it’s a pretty simple solution, but I just can’t see it now. Been staring at this stuff for too long today and brain is tired. Any help attempts are greatly appreciated. Thank you.

Ya right.

_root.enemy1.explodeMC.popexplode.start(0, 1);
_root.enemy1.explodeMC.popexplode.setVolume(popexplodeVolume);

if you put this you make reference to the first (enemy1) MC, but you are making dupes from it and call’em “enemy”+i. So you MUST use “this”, for avoid this problem. Make all your references to “enemy1”, be “this”, of course if they are into the same process.

greetz

Uuugghh. See, I knew it was simple… It works now, thanks for replying, Crab.

…Guess I need to get up once every 3 hours or so and get a glass of water or something…