3 Replies Latest reply on Feb 8, 2014 4:27 PM by kglad

    Referencing multiple movieclips with similar instance names


      I have a player movieclip and six obstacle movieclips with instance names "obs1", "obs2", up to "obs6". If the player hits any of the obstacles, the variable dead is set to true. The code I have at the moment is:


      if (hitTest(_root.obs1)||hitTest(_root.obs2)||hitTest(_root.obs3)||hitTest(_root.obs4)||hitT est(_root.obs5)||hitTest(_root.obs6)) {

      dead = true



      Since that if statement looks pretty ugly as it is, I wanted to know whether it was possible to reference all movieclips with the instance name "obs" followed by a number. I believe it involves square brackets, something like:




      Can anyone give me some pointers?

      (I'm using Flash CS3 and ActionScript 2.0)