{"id":78,"date":"2008-11-02T00:01:10","date_gmt":"2008-11-02T07:01:10","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=42"},"modified":"2008-11-02T00:01:10","modified_gmt":"2008-11-02T07:01:10","slug":"random-choice","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=78","title":{"rendered":"Random Choice"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nfunction randomChoice(...args:Array):*{\r\n\treturn args&#x5B;int(Math.random()*args.length)];\r\n}\r\n\r\n\/\/ choose randomly from a number of different values\r\nvar val:* = randomChoice(10, &quot;Hello&quot;, &quot;0xFF0000&quot;, 1000);\r\n\r\n\/\/ choose a random color (in this case red, green or blue)\r\nvar randColor:uint = randomChoice(0xFF0000, 0x00FF00, 0x0000FF);\r\n\r\ntrace(val);\r\ntrace(randColor);\r\n<\/pre>\n<p>The function randomChoice() takes any number of arguments and spits one of them back randomly. Just a handy function to have around&#8230; I especially like to use this function to choose from a handful of colors.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>function randomChoice(&#8230;args:Array):*{ return args&#x5B;int(Math.random()*args.length)]; } \/\/ choose randomly from a number of different values var val:* = randomChoice(10, &quot;Hello&quot;, &quot;0xFF0000&quot;, 1000); \/\/ choose a random color (in this case red, green or blue) var randColor:uint = randomChoice(0xFF0000, 0x00FF00, 0x0000FF); trace(val); trace(randColor); The function randomChoice() takes any number of arguments and spits one of them back [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,23],"tags":[],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-functions","category-random"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/78","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=78"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}