3 Replies Latest reply on Feb 1, 2007 9:02 AM by kglad

    Dynamic code inside Event Handlers with Loop Problem

    michaeldorian
      Hi,

      What I am trying to do is dynamically assign a rollout and over behavior to each movieclip with a certain name on my stage. I'm looping through and attaching a function to each movieclip's event. So far that works. All the clips on roll out and over do something. However the problem I'm having is dynamically changing the values in each function for each different movieclip in a loop. For example I store the the clip I'm targeting original X and Y coordinates in an array which I push in the value on each loop. I trace it out to test and it traces out correctly on each loop each value of X and Y for that clip. The problem I am having is I'm try to call the orgX and orgY on each loop and tie that to each function but all the clips use the last value in the array. It is not dynamically attaching the new orgX and orgY to each clips individual RollOut Event. All the RollOut and Over events are invoked for each clip but when I try to put any dynamic code in the function it always only uses the last value. Even if I put a trace into the RollOver Event and try to trace the clips movieclip instance name all the clips trace the last clip name on rollover. My logic seems correct but does it have to do with how flash at runtime attaches events? How can I fix this problem?