2 Replies Latest reply on Jun 5, 2006 12:00 PM by gregmax17

    Big time help with the for loop

    gregmax17 Level 1
      I am trying to detect if a bullet hits an enemy on the stage. This is what I have for the bullet (this works just fine):

      var newname = "bullet_"+bullet;
      _root.attachMovie("bullet", newname, bullet+100);
      _root[newname]._rotation = player._rotation;
      _root[newname]._y = player._y;
      _root[newname]._x = player._x;
      _root[newname].onEnterFrame = function() {
      var bullet_speed = 6;

      then I use a for loop to detect if it hits any enemies (this is where it doesn't work):

      for( var a = 0; a <= 21; a++) {
      if(this.hitTest(_root['map.enemy_'+a+'.body])) {
      _root['enemy_'+a+'_hit'] = true;
      _root.reload = false;

      I have also trid using this['map.enem.......'], but that doesn't work either. It will for it I don't use a for loop, and just type in one at a time, but I don't want to type it all in! Why is this for loop not working?