AS: Main
This is a very simple tutorial assuming you know how to use Functions
Did you ever want to time a function to run outside onEnterFrame? every specific amount of time? for example ever second? every 1/20th of a second, every minute?
this is very useful for the following
autosave for games
fast and slow motion, dynamically changing the FPS
Typewriter Effect
and many others...
The concept is quite simple, flash lets you set and remove intervals, intervals are those handlers who trigger every specified amount of time. every interval has an ID, a number that is your reference to that interval.
an interval has a function, a timed (in miliseconds) and an ID
_root.stop;
id = setInterval(function () {
_root.nextFrame();
}, 200);
this for example sets the FPS on _root to 5, nice eh?
the syntax is
idvariable=setInterval (f:Function,interval);
if you want to stop the interval you just type
clearInterval (idvariable);
now let's say I want to trace "lolk" every 5 seconds, all I have to do is
idvariable=setInterval(function(){
trace("hello");
},5000);
I will cover passing parameters to functions set in setInterval later, but it's usually not that importnet
post any questions