setInterval
I often see questions about setInterval on flashcoders, so I thought I'd share my comments here. This applies to both Flash and JavaScript programming...
Intervals are not a problem as long as you use them correctly. Just make sure for every setInterval() call you have a corresponding clearInterval() call. Usually the clearInterval() is within your interval event handler function, so once the interval end condition is met, there's no way for your code to exit without hitting it.
I've been doing things this way for a long time, and I can't even remember the last time that I had a runaway interval problem. There's no need for an IntervalManager class if you don't want to deal with that. (Nothing wrong with it, but it might be overkill.)
Of course onEnterFrame is fine too if you're doing something in the context of a MovieClip, but that may not always be the case. And with that there's a danger too that you need to look out for. If a MovieClip already has an onEnterFrame handler -- say something you loaded externally that was created by a different developer -- you could overwrite it!
Intervals are not a problem as long as you use them correctly. Just make sure for every setInterval() call you have a corresponding clearInterval() call. Usually the clearInterval() is within your interval event handler function, so once the interval end condition is met, there's no way for your code to exit without hitting it.
//PSEUDOCODE
var myInterval = setInterval(myFunc, 200);
myFunc(){
//do stuff
if(endCondition == true){
clearInterval(myInterval);
}
}
I've been doing things this way for a long time, and I can't even remember the last time that I had a runaway interval problem. There's no need for an IntervalManager class if you don't want to deal with that. (Nothing wrong with it, but it might be overkill.)
Of course onEnterFrame is fine too if you're doing something in the context of a MovieClip, but that may not always be the case. And with that there's a danger too that you need to look out for. If a MovieClip already has an onEnterFrame handler -- say something you loaded externally that was created by a different developer -- you could overwrite it!
21 Comments:
There are a few traps for new users:
You can get some weird interval issues if you don't clear the old interval before starting a new one. I always add this line to check if there is already and in terval running and clear it before starting a fresh one:
private function initRenderInterval()
{
// kill any old intervals :)
if (_intervalID !=null)
{
clearInterval(_intervalID);
}
_intervalID = setInterval(this, "getStatus", _frequency);
}
some people also get issues when they don't scope the interval id correctly. If you store the interval on an annonymous object or within a class, you have to pass in a differnt number of params to the set interval call like:
this.intervalID = setInterval(this, "traceUsername", 1000, this.username);
as opposed to the standard:
intervalID = setInterval(traceUsername, 1000, username);
By
Aran, at 8:58 PM
there is huge issue on timing,
try tracing time between calls with setInterval and onEnterFrame used for timed function
I will post you soon my class which use onEnterFrame for time firing functions,
also there is few times when people had problem with setInterval
later then
By
Anonymous, at 3:03 AM
wow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro goldwow power leveling
wow powerleveling
world of warcraft power leveling
ffxi power leveling
ffxi powerleveling
ffxi
ffxi gil
age of conan
lotro powerleveling
lotro power leveling
lotro gold
By
wow power leveling, at 10:52 PM
runescape money runescape gold runescape gold runescape money buy runescape gold buy runescape money runescape money runescape gold wow power leveling wow powerleveling Warcraft Power Leveling Warcraft PowerLeveling buy runescape gold buy runescape money runescape items runescape accounts runescape gp dofus kamas buy dofus kamas Guild Wars Gold buy Guild Wars Gold lotro gold buy lotro gold lotro gold buy lotro gold lotro gold buy lotro gold runescape money runescape power leveling runescape money runescape gold dofus kamas cheap runescape money cheap runescape gold Hellgate Palladium Hellgate London Palladium Hellgate money Tabula Rasa gold tabula rasa money Tabula Rasa Credit Tabula Rasa Credits Hellgate gold Hellgate London gold wow power leveling wow powerleveling Warcraft PowerLeveling Warcraft Power Leveling World of Warcraft PowerLeveling World of Warcraft Power Leveling runescape power leveling runescape powerleveling eve isk eve online isk eve isk eve online isk tibia gold Fiesta Silver Fiesta Gold SilkRoad Gold buy SilkRoad Gold runescape accounts buy runescape accounts rs2 accounts buy rs2 accounts runescape power leveling rs2 power leveling FFXI Gil buy FFXI Gil gaia gold buy gaia gold buy dofus kamas buy dofus kamas dofus kamas runescape accounts buy runescape accounts rs2 accounts buy rs2 accounts runescape power leveling rs2 power leveling rs2 gold buy rs2 gold runescape
By
Anonymous, at 5:51 PM
runescape money runescape gold tibia item tibia gold runescape accounts tibia money runescape gp buy runescape gold tibia gold tibia item buy runescape money runescape items tibia money
By
Anonymous, at 12:10 AM
???
???
??????
??
???
???
????
????
???
???
???
??????
??
???
???
???
????
????
????
???
???
????
????
????
?????
????
?????
?????
?????
?????
????
???
????
????
?????
?????
????
?????
?????
?????
???
??
???
??
???
???
??????
???
????
???
???
???
?????
???
???
????
???
???
???
????
????
?????
?????
?????
???
???
????
????
????
???
?????
?????????
???
?????
???
????
????
????
????
????
?????
????
????
???
??????
???
????
???
???
?????????
???????
????
??A???
????
?????
?????
??
????
????
???
???
??????
???
???
???
?????????
???????
????
????
????
????
????
?????
????
????
???
??????
???
????
???
???
?????????
???????
????|??A???
????|??B???
????|?????|?????
???|????|???|??
??|????|??
???|??
???|???|??????|???|???
????????????????
???|?????????|???????
????
??A???
????
??B???
????
?????
?????
???
????
???
??
????
????
???
??
???
???
??????
???
???
????
?????
?????
?????????
?????
??
????
????
????
????
????
????
????
????
?????
????
?????
????
??
???
???
????
??
???
????
????
???
???
??????
???
?????
?????
???
???
???
????
?????
?????
??
?????????
???????
???????
??????
????
?????
???
?????
?????
???
?????
?????
???
???
???
?????
?????
???
???
???
???
????
????
????
????
????
?????
????
????
???
??????
???
????
???
???
?????????
???????
????
??A???
????
??B???
????
?????
?????
???
????
???
??
????
????
???
??
???
???
??????
???
???
????
?????
?????
?????????
?????
??
???
????
????
????
????
????
????
??
???
????
???
???
??????
???
???
??????
?????
???
???
??????
?????
???
???
??????
?????
???
???
???
???
??????
??????
?????
?????
???
???
??????
?????
???
???
??????
?????
???
???
??????
???
???
???
???
??????
??
??
??
??
???
????
????
????
????
??
????
???
????
???
??
???
???
????
????
??
???
???
????
????
??
??
???
???
???
???
????
????
????
????
??
???
???
????
????
??
???
???
????
????
??
???
???
????
????
??
??
??
???
????
??
????
??
????
????
??
????
????
???
??
????
????
???
????
??
????
????
???
????
??
??
????
????
????
????
???
???
????
????
??
??
????
????
????
????
???
???
????
????
??
??
??
????
????
????
????
????
????
???
???
???
????
????
????
??
??
??
????
????
????
????
????
???
???
????
????
??
??
??
??
?????
????
??
?????
?????
?????
?????
?????
????
?????
???
????
?????
????
?????
?????
?????
????
????
?????
????
????
????
??4S???
?????
???
????
????
????
????
????
???
????
????
????
????
????
???
????
????
????
????
????
????
????
???
????
????
??
??
By
Anonymous, at 12:40 AM
slantedhole -
slantedholes -
sugarxxxlesbian -
sugarxxxlesbians -
sweet8teen -
teenblowjobtryout -
teenblowjobtryouts -
teen ciara -
teenciara -
teendreamer -
teendreamers -
teenmptation -
teenmptations -
thepornstararchive -
tightcherries -
tinysecret -
tinysecrets -
trannystar -
trannystars -
twistedmovies -
tylerfaith -
ultimatehandjob -
ultimatehandjobs -
undergroundasian -
vivid -
vividamateur -
vividamateurs -
vividgirl -
vividgirls -
vividman -
vividstrickledpink -
weshallovercum -
whiteboyblackgirl -
whiteboysblackgirls -
xxxasianhardcore -
creamed feet -
fucked tits -
fuckedtits -
motherdaughterfuck -
mother daughter fuck -
penetration tease -
sleep assault -
spanked and abused -
spankedandabused -
247sexcams -
afro sluts -
afrosluts -
all teen video -
allteenvideo -
dark meat white treat -
exposed celebrity -
farmer sluts -
lust4her -
megatitty -
amazon shemales -
anns xxx -
badstars -
free passes now -
finallyeighteen -
desperately horny housewives -
freepassesnow -
fuck butter -
fuckbutter -
high speed smut -
highspeedsmut -
penetration tease -
sleep assault -
high speed smut -
penetrationtease -
sleepassault -
kalifornication -
lesbiansweat -
fucked tits -
desperately horny housewives -
exotic transsexuals -
mother daughter fuck -
lesbian sweat -
anal sorority -
analsorority -
all inclusive pass -
spanked and abused -
247 sex cams -
allinclusivepass -
all teen video -
dark meat white treat -
darkmeatwhitetreat -
creamedfeet -
asiansizzle -
asian sizzle -
di xxx -
dixxx -
fuck my brazilian ass -
mega titty -
amazon shemales -
amazonshemales -
fuckmybrazilianass -
hiddensexcam -
pornigraphic -
annsxxx -
anns xxx -
bad stars -
exposedcelebrity -
lust 4 her -
mega titty -
farmer sluts -
farmsersluts -
pornigraphic -
real drunk girls -
slut bus -
amateur academy -
meat insertions -
strapon mom -
doctorstroke -
finally eighteen -
ryans beach house -
ryansbeachhouse -
ryans beach house -
set top sex -
settopsex -
set top sex -
whale cock -
kalifornication -
lesbian sweat -
xxxquirer -
all inclusive pass -
creamed feet -
xxx quirer -
tinys black adventures -
all reality pass -
anal sorority -
asian sizzle -
all star porn girls -
barefoot maniacs -
fuck my brazilian ass -
hidden sex cam -
big league facials -
big tit patrol -
realdrunkgirls -
real drunk girls -
slutbus -
big cock teen addiction -
blind date bangers -
bus stop whores -
casting couch teens -
coeds need cash -
Giants Black Meat White Treat -
Horny Spanish Flies -
I Spy Camel Toe -
Mr. Chew's Asian Beaver -
Pimp My Black Teen -
Please Bang My Wife -
Pump That Ass -
amateuracademy -
doctor stroke -
Reality Pass Plus -
See Her Squirt -
ashley ls -
extra big dicks -
extrabigdicks -
ashley lightspeed -
extra big dicks -
Teeny Bopper Club -
ass licking xxx -
desperatelyhornyhousewives -
exotictranssexuals -
exotic transsexuals -
phat white booty -
squirterz -
moes white booty hoes -
moeswhitebootyhoes -
older women love cock too -
olderwomenlovecocktoo -
whalecock -
xxx quirer -
one crazy night -
onecrazynight -
see her gag -
seehergag -
see her gag -
shemale beach -
shemalebeach -
shemale hookups -
xporn -
ashley lightspeed -
ashleylightspeed -
tranny extasy -
unshavenpubes -
matureuniform -
me and my pussy -
meatinsertions -
straponmom -
strapon mom -
amber at home -
lesbians from heaven -
meandmypussy -
creampie freaks -
asslickingxxx -
ass licking xxx -
doctor stroke -
deep throating blowjobs -
hood bobbin -
creampie party -
amberathome -
meandmypussy -
chubbysecrets -
lesbiansfromheaven -
trannyextasy -
unshaven pubes -
matuercaress -
outrageous grannies -
amber at home -
bangingthebiway -
banging the bi way -
bangingthebiway -
older women love cock too -
onecrazynight -
dude bang -
dudebang -
dude bang -
jenakayricci -
mandi rose fanelli -
mandirosefanelli -
phat white booty -
shemale beach -
shemale hookups -
shemalehookups -
phatwhitebooty -
squirterz -
adult video lounge -
adultvideolounge -
adult video lounge -
black semen lovers -
blacksemenlovers -
black semen lovers -
cherrypotter -
cherry potter -
cherrypotter -
miss mya -
real ass munchers -
realassmunchers -
chubby secrets -
mature uniform -
me and my pussy -
meat insertions -
mature caress -
chubby secrets -
lesbians from heaven -
mature uniform -
outrageousgrannies -
tranny extasy -
unshavenpubes -
ass to mouth angels -
asstomouthangels -
creampie freaks -
jena kay ricci -
mandi rose fanelli -
creampiefreaks -
creampieparty -
creampie party -
deep throating blowjobs -
deepthroatingblowjobs -
hoodbobbin -
mature caress -
outrageousgrannies -
hood bobbin -
miss mya -
missmya -
real ass munchers -
allinclusivepass -
allinclusivepass -
all inclusive pass -
all reality pass -
all star porn girls -
barefoot maniacs -
big cock addiction -
big league facials -
big tit patrol -
bikini contest porn -
blind date bangers -
bus stop whores -
casting couch teens -
coeds need cash -
creamed feet -
fucked tits -
giants black meat white treat -
horny spanish flies -
i spy cameltoe -
milf hunter -
mother daughter fuck -
mr chews asian beaver -
penetration tease -
pimp my black teen -
please bang my wife -
pump that ass -
reality pass plus -
see her squirt -
sleep assault -
spanked and abused -
teeny bopper club -
the big swallow -
tinys black adventures -
tongues and toys -
xxx proposal -
all inclusive pass -
allinclusivepass -
all inclusive pass -
all reality pass -
all star porn girls -
barefoot maniacs -
big cock addiction -
big league facials -
big tit patrol -
bikini contest porn -
blind date bangers -
bus stop whores -
casting couch teens -
coeds need cash -
creamed feet -
fucked tits -
giants black meat white treat -
horny spanish flies -
i spy cameltoe -
milf hunter -
mother daughter fuck -
mr chews asian beaver -
penetration tease -
pimp my black teen -
please bang my wife -
pump that ass -
reality pass plus -
see her squirt -
sleep assault -
spanked and abused -
teeny bopper club -
the big swallow -
tinys black adventures -
tongues and toys -
xxx proposal -
allinclusivepass -
allinclusivepass -
all inclusive pass -
all reality pass -
all star porn girls -
barefoot maniacs -
big cock addiction -
big league facials -
big tit patrol -
bikini contest porn -
blind date bangers -
bus stop whores -
casting couch teens -
coeds need cash -
creamed feet -
fucked tits -
giants black meat white treat -
horny spanish flies -
i spy cameltoe -
milf hunter -
mother daughter fuck -
mr chews asian beaver -
pimp my black teen -
please bang my wife -
pump that ass -
reality pass plus -
see her squirt -
sleep assault -
spanked and abused -
teeny bopper club -
the big swallow -
tinys black adventures -
tongues and toys -
xxx proposal -
creamed feet -
all inclusive pass -
all reality pass -
all star porn girls -
barefoto maniacs -
big cock addiction -
big league facials -
big tit patrol -
bikini contest porn -
blind date bangers -
bus stop whores -
casting couch teens -
coeds need cash -
creamedfeet -
creamed feet -
fucked tits -
giants black meat white treat -
horny spanish flies -
i spy cameltoe -
milf hunter -
mother daughter fuck -
mr chews asian beaver -
penetration tease -
pimp my black teen -
please bang my wife -
pump that ass -
reality pass plus -
see her squirt -
sleep assault -
spanked and abused -
teeny bopper club -
the big swallow -
tinys black adventures -
tongues and toys -
xxx proposal -
creamed feet -
all inclusive pass -
all reality pass -
all star porn girls -
barefoot maniacs -
big cock addiction -
big league facials -
big tit patrol -
bikini contest porn -
blind date bangers -
bus stop whores -
casting couch teens -
coeds need cash -
creamedfeet -
creamed feet -
giants black meat white treat -
horny spanish flies -
i spy cameltoe -
milf hunter -
mother daughter fuck -
mr chews asian beaver -
penetration tease -
pimp my black teen -
please bang my wife -
pump that ass -
reality pass plus -
see her squirt -
sleep assault -
spanked and abused -
teeny bopper club -
the big swallow -
tinys black adventures -
tongues and toys -
xxx proposal -
creamed feet -
all inclusive pass -
all reality pass -
all star porn girls -
barefoot maniacs -
big cock addiction -
big league facials -
big tit patrol -
bikini contest porn -
blind date bagners -
bus stop whores -
casting couch teens -
coeds need cash -
creamedfeet -
creamed feet -
giants black meat white treat -
horny spanish flies -
i spy cameltoe -
milf hunter -
mother daughter fuck -
mr chews asian beaver -
penetration tease -
pimp my black teen -
please bang my wife -
pump that ass -
reality pass plus -
see her squirt -
teeny bopper club -
the big swallow -
tinys black adventures -
tongues and toys -
xxx proposal -
fucked tits -
all inclusive pass -
all reality pass -
all star porn girls -
barefoot maniacs -
big cock addiction -
big league facials -
big tit patrol -
bikini contest porn -
blind date bangers -
bus stop whores -
casting couch teens -
coeds need cash -
creamed feet -
fucked tits -
giants black meat white treat -
horny spanish flies -
i spy cameltoe -
milf hunter -
mother daughter fuck -
mr chews asian beaver -
pimp my black teen -
please bang my wife -
pump that ass -
reality pass plus -
see her squirt -
teeny bopper club -
the big swallow -
tinys black adventures -
tongues and toys -
xxx proposdal -
fucked tits -
By
Anonymous, at 9:34 PM
all reality pass -
all star porn girls -
barefoot maniacs -
big cock addiction -
big league facials -
big tit patrol -
bikini contest porn -
blind date bangers -
bus stop whores -
casting couch teens -
coeds need cash -
creamed feet -
fuckedtits -
fucked tits -
giants black meat white treat -
horny spanish flies -
i spy cameltoe -
milf hunter -
mother daughter fuck -
mr chews asian beaver -
pimp my black teen -
please bang my wife -
pump that ass -
reality pass plus -
see her squirt -
teeny bopper club -
the big swallow -
tinys black adventures -
tongues and toys -
xxx proposal -
fucked tits -
all reality pass -
all star porn girls -
barefoot maniacs -
big cock addiction -
big league facials -
big tit patrol -
bikini contest porn -
blind date bangers -
bus stop whores -
casting couch teens -
coeds need cash -
creamed feet -
fuckedtits -
fucked tits -
giants black meat white treat -
horny spanish flies -
i spy cameltoe -
milf hunter -
mother daughter fuck -
mr chews asina beaver -
pimp my black teen -
please bang my wife -
pump that ass -
reality pass plus -
see her squirt -
teeny bopper club -
the big swallow -
tinys black adventures -
tongues and toys -
xxx proposal -
mother daughter fuck -
all reality pass -
all star porn girls -
barefoot maniacs -
big cock addiction -
big league facials -
big tit patrol -
bikini contest porn -
blind date bangers -
bus stop whores -
casting couch teens -
coeds need cash -
creamed feet -
fucked tits -
giants black meat white treat -
horny spanish flies -
i spy cameltoe -
milf hunter -
motherdaughterfuck -
mother daughter fuck -
mr chews asian beaver -
penetration tease -
pimp my black teen -
please bang my wife -
pump that ass -
reality pass plus -
see her squirt -
sleep assault -
teeny bopper club -
the big swallow -
tinys black adventures -
tongues and toys -
xxx proposal -
mother daughter fuck -