Solved

Timer-Super Easy!!!

Posted on 2003-11-05
3
169 Views
Last Modified: 2010-04-03
Hi. I wanted to create a slide show w/ AUTOPLAY function (which is actually my problem)
I'd appreciate a lot if someone of you could please write a simple short ActioScript script (used with a BUTTON) that would automaticaly change the frame in a period of time (Also w/ stop function if possible).

Thanks, really
0
Comment
Question by:the-script
3 Comments
 

Accepted Solution

by:
Rouneh earned 30 total points
ID: 9707183
This should work if you're using Flash MX

--- Put this in your timeline ---
var skipInterval = 1000; // Delay before frame changes (in milliseconds)
function toggleAutoPlay() {
   if (autoPlayTimer != undefined)
      clearInterval(autoPlayTimer); // Turns off the timer if you click the button while autoplay is running
   else {
      autoPlayTimer = setInterval(
         function() { gotoAndStop((_root._currentframe < _root._totalframes)?_root._currentframe+1:1);},
         skipInterval
      ); // This bit sets the timer and makes sure to start at the beginning if you're at the last frame.
   }
}
stop();

--- Put this in your button ---
on(release) {
   toggleAutoPlay(); // You can click the same button to start and stop the autoplay sequence.
}

If you're not using Flash MX, however, things are a bit more complicated as there's no <setInterval> function in the earlier versions. Let me know if that's a problem.

Regards,
Rouneh
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now