setInterval working only once

  • panzhuli
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Oct 14, 2004
  • Posts: 135
  • Loc: Cleveland
  • Status: Offline

Post October 22nd, 2008, 3:22 pm

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!
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 22nd, 2008, 3:22 pm

  • Flanders
  • Beginner
  • Beginner
  • User avatar
  • Joined: Feb 27, 2006
  • Posts: 48
  • Loc: Reno, Nevada US
  • Status: Offline

Post October 24th, 2008, 11:35 am

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 48 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.