{"id":145,"date":"2009-01-05T00:00:16","date_gmt":"2009-01-05T07:00:16","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=472"},"modified":"2009-01-05T00:00:16","modified_gmt":"2009-01-05T07:00:16","slug":"constants-as-function-argument-defaults","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=145","title":{"rendered":"Constants as Function Argument Defaults"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nconst RADIUS = 10;\r\nconst COLOR = 0xCCCCCC;\r\n\r\nfunction createCircle(xp:Number, yp:Number, radius:Number = RADIUS, col:uint = COLOR):void{\r\n\tvar c:Sprite = new Sprite();\r\n\tc.graphics.beginFill(col);\r\n\tc.graphics.drawCircle(xp, yp, radius);\r\n\taddChild(c);\r\n}\r\n\r\n\/\/ optional last 2 values are populated with const defaults\r\ncreateCircle(100,100);\r\n\/\/ optional color value is populated with default 0xCCCCCC;\r\ncreateCircle(200,100, 20);\r\n\/\/\r\ncreateCircle(300,100, 50,0x0000FF);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>const RADIUS = 10; const COLOR = 0xCCCCCC; function createCircle(xp:Number, yp:Number, radius:Number = RADIUS, col:uint = COLOR):void{ var c:Sprite = new Sprite(); c.graphics.beginFill(col); c.graphics.drawCircle(xp, yp, radius); addChild(c); } \/\/ optional last 2 values are populated with const defaults createCircle(100,100); \/\/ optional color value is populated with default 0xCCCCCC; createCircle(200,100, 20); \/\/ createCircle(300,100, 50,0x0000FF);<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,68],"tags":[3,4],"class_list":["post-145","post","type-post","status-publish","format-standard","hentry","category-functions","category-variables","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/145","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=145"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/145\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}