
{"id":2148,"date":"2015-04-05T19:00:06","date_gmt":"2015-04-05T18:00:06","guid":{"rendered":"http:\/\/www.matthijskamstra.nl\/blog\/?p=2148"},"modified":"2015-08-28T21:12:19","modified_gmt":"2015-08-28T20:12:19","slug":"delay-call-timer-delay-in-haxe","status":"publish","type":"post","link":"https:\/\/www.matthijskamstra.nl\/blog\/2015\/04\/05\/delay-call-timer-delay-in-haxe\/","title":{"rendered":"Delay call, Timer delay in Haxe"},"content":{"rendered":"<p>When I started programming for <strong>as3<\/strong>, I started to collect little snippets of code. Some to explain the transition from <strong>as2<\/strong> to <strong>as3<\/strong>. And some just to have one place to go to when I forgot how it worked&#8230; 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:<\/p>\n<h2>How do you call a function with delay? (without a tweening engine!)<\/h2>\n<p>Not that difficult:<\/p>\n<p><a href=\"http:\/\/api.haxe.org\/haxe\/Timer.html\" target=\"_blank\">http:\/\/api.haxe.org\/haxe\/Timer.html<\/a><\/p>\n<p><code>haxe.Timer.delay(someFunction, 1000);<\/code><br \/>\nBut what if you want to send some extra parameters?<\/p>\n<h2>How do you call a function (with parameters) with delay?<\/h2>\n<p>(without a tweening engine!) I found my answer on stack.<\/p>\n<p><strong>update1 : this only works with flash, java, js, python<\/strong><\/p>\n<p><code>haxe.Timer.delay(callback(someFunction,\"abc\"), 10);<\/code><\/p>\n<p>But I prefer a more readable version (probably because it looks very much like the javascript version), also mentioned in the same post.<br \/>\n<code>haxe.Timer.delay(function () { func(arg1, arg2); }, delay);<\/code><\/p>\n<p><strong>update 2:<\/strong> needed it for a quick prototype in Haxe \/ Neko<\/p>\n<p><code>Sys.sleep(2);<br \/>\n\/\/ do something delayed<\/code><\/p>\n<p>Source: <a href=\"http:\/\/stackoverflow.com\/questions\/3063286\/pass-arguments-to-a-delayed-function-with-haxe\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/3063286\/pass-arguments-to-a-delayed-function-with-haxe<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230; I decided to do it also for Haxe and Openfl. For some reason I forget some [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[360,385],"tags":[387,412,383,386],"class_list":["post-2148","post","type-post","status-publish","format-standard","hentry","category-haxe","category-openfl","tag-delay","tag-haxe","tag-openfl","tag-timer"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/2148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/comments?post=2148"}],"version-history":[{"count":10,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/2148\/revisions"}],"predecessor-version":[{"id":2244,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/2148\/revisions\/2244"}],"wp:attachment":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/media?parent=2148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/categories?post=2148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/tags?post=2148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}