2 Replies Latest reply on Oct 2, 2007 8:24 AM by SolBrad69

    Problems giving multipile movies actions with for loop

    SolBrad69
      Hi all happy flash coder people

      I am really hoping someone can help me with this

      What i want to do is assign actions to each individual movieclip using a for loop.. let me explain

      Say i have 5 MovieClips on the stage... With instance names clip1, clip2, clip3....

      Now what i want to do is assign a OnRollOver and OnRelease to each 1
      So individual code for each would be something like this.

      _root.Clip1.OnRollOver = function()
      {
      _root.Clip1.gotoAndPlay(2);
      trace("clip1 clicked")
      }
      _root.Clip2.OnRollOver = function()
      {
      _root.Clip2.gotoAndPlay(2);
      trace("clip2 clicked")
      }

      now instead of copy pasting this over and over again for however many clips i have i wanted to put it in a for loop like so

      for(i=1; i<6; i++)
      {
      _root["Clip" + i].OnRollOver = function()
      {
      _root["Clip" + i].gotoAndPlay(2);
      trace("Clip" + i + "clicked")
      }
      }

      the problem is this does not work... and all the trace statements just say clip4 clicked

      how do i solve this problem, what am i doing wrong?

      Please if anyone can help i would appreciate it so much

      Thanks
      Brad