Article by Alwyn.
Published: July 9, 2008 at 15:56
Category: Actionscript 2
Settimeout in AS2 classes
< back to overviewI know this has been mentioned on other blogs but I just wanted to write about this myself
(first blogposts
).
The problem when dealing with the global timeout method in actionscript 2 classes was and still is that you are not able to use the setTimeout global function. Whereas setInterval is still accessible. But since we do not want to use the buggy setInterval method anymore (think of unexplained disappearing pointers…), I started looking for a way to access the much better setTimeout method (which is probably one of the best additions to as2). Of course also this method also lacks some of the great powers of the timer class in as3 but since we’re dealing with AS2, let’s just stick with that.
So how can you access the global setTimeout function? Use the global pointer as followed:
_global.setTimeout(this, "functionname", intervalTime [, params] );
Notice the this parameter, this is important when using setTimeout in classes, else flash doesn’t know where to find the functionname.
In addition to this, you can also use the _global.clearTimeout(timerId) function in the same way.
Although this works like a charm, there are still some problems with referencing to timeouts. But that is just really old news
.
Comments
No comments yet











go to: