2 Replies Latest reply on Jan 31, 2007 6:50 AM by Red Box New Media

    Probs with setInterval and programmatic animation

    Red Box New Media
      Hi all

      Further to a recent post about using setInterval to create animation on a dynamically created menu item mc; I'm now trying to refine this process but once again not having much luck! The Flash front end is pulling in the menu data from an XML file, duplicating a menu item movie clip that has a dynamic text field in it and then populating that text field with the data from the XML file. This was all fine and dandy and working with no issues until I tried to add some interaction motion to the menu item mc.

      Initially I added a tween within the menu item mc that shifted the text field, (inside another mc), to the right and changed it's colour. The control of this happened in the rollOver statement back in the code. That was fine until the animation of the menu item embedded mc reached a keyframe - at that point any data that had been pulled into the text field vanished! So, my first question is, is there any easy fix to that?

      So, I figured I'd go about creating the animation programmtically. kglad helped me out last night with setInterval, but I'm having two problems now. I'm using an if statement inside the setInterval function to try and clear the interval when it reaches a certain point - i.e. when I've slid the menu item 50 pixel to the right. Seems to be working - however getting it to reverse back into position on rollOut is proving tricky AND it only moves the same menu item - regardless of which item you rollOver ... which is odd. I guess I'm not being specific enough in telling it which item to move, but I can't figure that out. So, my two questions here are 1). Why is reversing the animation not working correctly on rollOut and 2). How can I let the rollOver code know exactly which menu item to control?

      Here's the code in full: