0 Replies Latest reply on Oct 20, 2010 5:55 PM by headlessgargoyle

    AS2 CS4 iterating through an array?

    headlessgargoyle

      Alright so i've had this problem for far too long here and i need help. first of all here's the code

      and if you can tell me how i can put it in more or less of a "code box" that makes it easier to read by including the indents, it would be also appreciated.

      function(){return A.apply(null,[this].concat($A(arguments)))}

      function(){return A.apply(null,[this].concat($A(arguments)))}

      class controller extends MovieClip

      {

      function NewBox()
      {
        if(number < 50)
        {
         timer = 0
         number +=1
         var box = _root.contentMain.attachMovie("name1", "name0"+number, number)
         box._y = position
         boxes.push(box)
         trace(boxes)
         if(position > 120)
         {
          var position1 = -1*position + 40
          _root.contentMain._y = position1
          if(_root.contentMain._y < -740){_root.contentMain._y = -740}
          if(_root.contentMain._y > -740){_root.scrollFace._y += 1.85}
         }
        }
      }
      function hilite()
      {
        if(prob > 0)
        {
         timer = 0
         var work2 = _root.contentMain.attachMovie("highliter", "highliter", number + chronos)
         work2._y = Math.floor(Math.random()*number)*17.4+ 17.4
         _root.contentMain._y = -1*work2._y + 20
        }
        if(prob < 0)
        {
         timer = 0
         var work1 = _root.contentMain.attachMovie("controller2","controller2",number+chronos+1)
         var work2 = _root.contentMain.attachMovie("highliter", "highliter", number+chronos)
         work1._x = -200
         work1._y = Math.floor(Math.random()*number)*17.4+ 17.4
         work2._y = work1._y
         _root.contentMain._y = -1*work1._y + 20
         controllers.push(work1)
         hiliters.push(work2)
        }
      }
      function MinusBox()
      {
        if(number > 1)
        {
         removeMovieClip(_root.contentMain.name0+number)
         number -= 1
        }
      }

      }

       

      function(){return A.apply(null,[this].concat($A(arguments)))}

      function(){return A.apply(null,[this].concat($A(arguments)))}

      class highliter extends MovieClip
      {
      var timer1
      function onLoad()
      {
        timer1 = 0
      }
      function onEnterFrame()
      {
        timer1 += 1
        if(timer1 > 72)
        {
         timer1 = 0
         this.removeMovieClip()
        }
        for(var i in _root.contentMain.controller1.controllers)
        {
         if(this.hitTest(_root.contentMain.controller1.controllers[i]))
         {
          this.removeMovieClip()
          _root.contentMain.controller1.hilite()
         }
        }
      }
      }

       


      now here's one problem, it only checks collisions for the first object in the array "controllers", and no others. and i want it to check for all objects

      and second of all, how can i refer to an object whose instance name includes a variable as seen in "function MinusBox"

      many many thanks for any help to my annoying problems.