Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Triggering an setInterval manualy

Posted on 2011-05-12
1
Medium Priority
?
316 Views
Last Modified: 2013-11-11
Hi,

I have a setInterval that runs in four seconds and can be paused with a play button. However, when it is unpaused I want the interval to run instantly rather than waiting another 4 seconds to run again.

Is there a way I can either:
Trigger the interval manually, with say, a function
Make the interval run instantly on the first run

Thanks, any help appreciated
0
Comment
Question by:andrewkhan
1 Comment
 
LVL 10

Accepted Solution

by:
Carnou earned 2000 total points
ID: 35747143
If you're using setInterval, the first parameter you have to pass to it is a function.
Simply make sure that the function is not an anonymous one, and you can call the function at any time.

Here's an example from http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary646.html

function callback1() {
      trace("interval called");
}

setInterval( callback1, 1000 );

In the example, callback1 will be called every second, but you can call callback1 at any other time that you want.
Make sure to call the function and then make the 4 second timer begin again when you're unpaused.

Hope this helps.

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
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.
Suggested Courses

564 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