This content has been marked as final. Show 5 replies
As you know what you are doing won't work. But it would be helpful to us to see what you mean by, "I've tried setInterval to slow it down..."
An interval should allow you to do what you want, so if it isn't working there is something else going on. So use the attach code button to attach only the parts of your code that are relavant to this problem. Then we can see if we can get you straightened out!
I attached the entire code.
Still not clear on what is happening. So are you not seeing the wait function trace? Or are you seeing it once for each myTracks and then it keeps on for ever?
Since you have the stuff at the bottom there indented were you thinking that the for loop would pause for the wait function to be called and then execute the attaching and all? Like you said before that isn't going to work.
A for loop executes (if possible) completely before each frame of your animation runs. There is no way to slow it or make it go one step at a time. What you need to do is spread the looping bit out over time and that is where the setInterval comes in. You need to set up some kind of counter -- outside of your XML object -- and then have the attaching and removing happen with that function.
Actually most everything in your for loop needs to be pulled outside of the onLoad and be put in a setInterval or an onEnterFrame.
Thanks Rothrock. I was thinking that I could pause the for loop. I took your suggestion and set a counter and am running the for loop for each storm track position causing the mc to animate.
Glad that worked out for you. The for-loop trap often gets folks who are first stepping into AS controlled animation. The two choices really are to use setInterval or to use an onEnterFrame event handler. So if you plan to do much more of this I would recommend trying some little experiments with each to learn about their respective strengths and weaknesses. Good luck.