When I started programming for as3, I started to collect little snippets of code. Some to explain the transition from as2 to as3. And some just to have one place to go to when I forgot how it worked… I decided to do it also for Haxe and Openfl. For some reason I forget some stuff easily. This is one I need often and forget easily:
How do you call a function with delay? (without a tweening engine!)
Not that difficult:
http://api.haxe.org/haxe/Timer.html
haxe.Timer.delay(someFunction, 1000);
But what if you want to send some extra parameters?
How do you call a function (with parameters) with delay?
(without a tweening engine!) I found my answer on stack.
update1 : this only works with flash, java, js, python
haxe.Timer.delay(callback(someFunction,"abc"), 10);
But I prefer a more readable version (probably because it looks very much like the javascript version), also mentioned in the same post.
haxe.Timer.delay(function () { func(arg1, arg2); }, delay);
update 2: needed it for a quick prototype in Haxe / Neko
Sys.sleep(2);
// do something delayed
Source: http://stackoverflow.com/questions/3063286/pass-arguments-to-a-delayed-function-with-haxe