[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 644
  • Last Modified:

setInterval

stop();
setInterval(this, "reFresh",1000);
function reFresh():Void{
      gotoAndPlay(1);
}

i have this code on the 30th frame of the movie, and i want it to go back to frame one every 1 second, but this code only works for the begining of the movie, after awhile it's all messed up, just wondering what is the proper way to implement it using AS, please help
0
koblongata
Asked:
koblongata
  • 2
1 Solution
 
Dushan De SilvaCommented:
Is there any extra actions available between frame1 and frame30?
And what is your frames per second(fps) rate. Because if your using it more than 30... then it will more than one second to go to 30th frame.. please explain more.

BR Dushan
0
 
Dushan De SilvaCommented:
sorry
"Because if your using it more than 30... " 
should corrected as
"Because if your using it less than 30... " 

BR Dushan
0
 
blue-genieCommented:
hi, your problem is because you're not clearing your interval.
what you need

stop();
var bob = setInterval(this, "reFresh", 1000);
function reFresh():Void {
      clearInterval(bob);
      gotoAndPlay(1);
}

reason being, it goes to frame 30, calls the method, goes to frame 1, then keeps calling that method, so it never returns to frame 30 - it doesn't get a chance to.

blu.
0
 
koblongataAuthor Commented:
thank ya
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now