{"id":76,"date":"2008-10-31T00:04:21","date_gmt":"2008-10-31T07:04:21","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=35"},"modified":"2008-10-31T00:04:21","modified_gmt":"2008-10-31T07:04:21","slug":"associative-array-function-call","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=76","title":{"rendered":"Associative Array Function Call"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nfor (var i:int = 0; i&lt;4; i++){\r\n\tthis&#x5B;&quot;phase&quot;+i]();\r\n}\r\n\r\nfunction phase0():void{\r\n\ttrace(&quot;phase 0&quot;);\r\n}\r\nfunction phase1():void{\r\n\ttrace(&quot;phase 1&quot;);\r\n}\r\nfunction phase2():void{\r\n\ttrace(&quot;phase 2&quot;);\r\n}\r\nfunction phase3():void{\r\n\ttrace(&quot;phase 3&quot;);\r\n}\r\n\r\n\/*\r\nwill output:\r\nphase 0\r\nphase 1\r\nphase 2\r\nphase 3\r\n*\/\r\n\r\n\/*\r\nWARNING: This code was written for fun. Use at your own risk.\r\n*\/\r\n<\/pre>\n<p>I was pleasantly surprised back in the AS1 days&#8230; when I discovered that associative array syntax worked along with function calls (why wouldn&#8217;t it?). There are some interesting tricks you can do with this technique&#8230;. will post some later&#8230;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>for (var i:int = 0; i&lt;4; i++){ this&#x5B;&quot;phase&quot;+i](); } function phase0():void{ trace(&quot;phase 0&quot;); } function phase1():void{ trace(&quot;phase 1&quot;); } function phase2():void{ trace(&quot;phase 2&quot;); } function phase3():void{ trace(&quot;phase 3&quot;); } \/* will output: phase 0 phase 1 phase 2 phase 3 *\/ \/* WARNING: This code was written for fun. Use at your own risk. *\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,32,17],"tags":[],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-arrays","category-associative-arrays","category-functions"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}