setInterval working only once

  • panzhuli
  • Graduate
  • Graduate
  • panzhuli
  • Posts: 135
  • Loc: Cleveland

Post 3+ Months Ago

Hi there - here's a bit of code...

Code: [ Select ]
 
movePresents = function(){
    for (i=1; i<=6; i++) {
        trace ("present"+i+"_mc");
        this["present"+i+"_mc"].nextFrame();
    }
    /*present1_mc.nextFrame();
    present2_mc.nextFrame();
    present3_mc.nextFrame();
    present4_mc.nextFrame();
    present5_mc.nextFrame();
    present6_mc.nextFrame();
    present7_mc.nextFrame();
    present8_mc.nextFrame();
    present9_mc.nextFrame();*/
};
presentInterval = setInterval(movePresents, 10000);
movePresents();
 
  1.  
  2. movePresents = function(){
  3.     for (i=1; i<=6; i++) {
  4.         trace ("present"+i+"_mc");
  5.         this["present"+i+"_mc"].nextFrame();
  6.     }
  7.     /*present1_mc.nextFrame();
  8.     present2_mc.nextFrame();
  9.     present3_mc.nextFrame();
  10.     present4_mc.nextFrame();
  11.     present5_mc.nextFrame();
  12.     present6_mc.nextFrame();
  13.     present7_mc.nextFrame();
  14.     present8_mc.nextFrame();
  15.     present9_mc.nextFrame();*/
  16. };
  17. presentInterval = setInterval(movePresents, 10000);
  18. movePresents();
  19.  


the first time the code is run (with the movePresents() call), it works. When it runs via the interval, it doesn't work, although the interval does run.

See the code commented out? the non-for loop code? that works.

Ideas?

thanks!
  • Flanders
  • Beginner
  • Beginner
  • User avatar
  • Posts: 48
  • Loc: Reno, Nevada US

Post 3+ Months Ago

http://whatdoiknow.org/archives/001890.shtml

This article illustrates your problem.

Code: [ Select ]
stop();
 
function movePresents(){
for(i=1;i<10;i++){
this["present"+i+"_mc"].nextFrame();
}
}
 
presentInterval=setInterval(this,"movePresents",1000);
  1. stop();
  2.  
  3. function movePresents(){
  4. for(i=1;i<10;i++){
  5. this["present"+i+"_mc"].nextFrame();
  6. }
  7. }
  8.  
  9. presentInterval=setInterval(this,"movePresents",1000);

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.