{"id":489,"date":"2010-03-09T10:51:07","date_gmt":"2010-03-09T17:51:07","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2801"},"modified":"2010-03-09T10:51:07","modified_gmt":"2010-03-09T17:51:07","slug":"bracket-syntax-reminder","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=489","title":{"rendered":"Bracket Syntax Reminder"},"content":{"rendered":"<p>If you haven&#8217;t looked at every post on this site it&#8217;s possible you&#8217;ve missed one of my favorite actionscript features&#8230;. Bracket Syntax:<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar s:Sprite = Sprite(addChild(new Sprite()));\r\ns&#x5B;&quot;x&quot;] = 100;\r\ns&#x5B;&quot;y&quot;] = 100;\r\n\r\ns&#x5B;&quot;graphics&quot;]&#x5B;&quot;beginFill&quot;](0xFF0000);\r\ns&#x5B;&quot;graphics&quot;]&#x5B;&quot;drawCircle&quot;](0,0,10);\r\n\r\nthis&#x5B;&quot;addChild&quot;](s);\r\n<\/pre>\n<p>If you don&#8217;t realize how powerful this is then there is something wrong with you (joking). If you don&#8217;t see how powerful this is, take some time and think about it. You can use it to avoid lots of annoying repetitive code in state machines for instance. It&#8217;s always important to keep things readable if you decide to go this route on a real project. <\/p>\n<p>[EDIT &#8230;.and as <a href=\"http:\/\/www.quasimondo.com\/\">Quasimondo<\/a> mentioned there is a notable performance hit when using this syntax. So don&#8217;t forget to keep that in mind.]<\/p>\n<p><a href=\"https:\/\/actionsnippet.com\/?p=37\"><br \/>\nHere is a very old post showing some of the power of this trick.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you haven&#8217;t looked at every post on this site it&#8217;s possible you&#8217;ve missed one of my favorite actionscript features&#8230;. Bracket Syntax: var s:Sprite = Sprite(addChild(new Sprite())); s&#x5B;&quot;x&quot;] = 100; s&#x5B;&quot;y&quot;] = 100; s&#x5B;&quot;graphics&quot;]&#x5B;&quot;beginFill&quot;](0xFF0000); s&#x5B;&quot;graphics&quot;]&#x5B;&quot;drawCircle&quot;](0,0,10); this&#x5B;&quot;addChild&quot;](s); If you don&#8217;t realize how powerful this is then there is something wrong with you (joking). If you don&#8217;t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,17],"tags":[3,14,4],"class_list":["post-489","post","type-post","status-publish","format-standard","hentry","category-dynamic","category-functions","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/489","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=489"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/489\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}