We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

setInterval

koblongata
koblongata asked
on
Medium Priority
706 Views
Last Modified: 2008-02-01
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
Comment
Watch Question

Dushan De SilvaTechnology Architect

Commented:
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
Dushan De SilvaTechnology Architect

Commented:
sorry
"Because if your using it more than 30... " 
should corrected as
"Because if your using it less than 30... " 

BR Dushan
Top Expert 2009
Commented:
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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
thank ya
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.