7 Replies Latest reply on May 29, 2008 6:15 AM by j9lemmon

    Prevent two movie clips from occupying same position

    j9lemmon Level 1
      As part of creating a game, I need to use actionscript to randomly place movie clips, on a grid spaced 50 pixels apart. This all works, but occasionally two movie clips are place at the same location. I want to prevent that. I'm guessing that I need a 'for' loop or an array. I'm thinking something like, but this is probably wrong:
      function putCollectiblesOnStage() {
      for (k=1; k<15;++)
      for (m=1; m<15;++) {
      if ((collectible_k._x = collectible_k.x) and (collectible_m._y = collectible_m._y)) {
      okToPlaceCollectible = false;
      }
      }
      }
      Thanks for any help
      John