{"id":324,"date":"2009-06-23T08:49:13","date_gmt":"2009-06-23T15:49:13","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1625"},"modified":"2009-06-23T08:49:13","modified_gmt":"2009-06-23T15:49:13","slug":"dot-syntax-from-string","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=324","title":{"rendered":"Dot Syntax from String"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nfunction dotSyntax(target:*, path:String):* {\r\n\tvar level:Array=path.split(&quot;.&quot;);\r\n\tvar curr:* = target;\r\n\tfor (var i:int = 0; i&lt;level.length; i++) {\r\n\t\tcurr=curr&#x5B;level&#x5B;i]];\r\n\t}\r\n\treturn curr;\r\n}\r\n\r\ntrace(dotSyntax(this, &quot;stage.stageWidth&quot;));\r\ntrace(dotSyntax(this, &quot;graphics&quot;));\r\ntrace(dotSyntax(this, &quot;root.loaderInfo.bytesTotal&quot;));\r\n\r\n\/*outputs something like:\r\n800\r\n&#x5B;object Graphics]\r\n1230\r\n*\/\r\n\r\n<\/pre>\n<p>This snippet shows how to parse dot syntax from a string. It does this by splitting the string and then using square bracket syntax. This is one of the main techniques that makes <a href=\"https:\/\/actionsnippet.com\/?p=1611\">yesterdays post<\/a> possible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>function dotSyntax(target:*, path:String):* { var level:Array=path.split(&quot;.&quot;); var curr:* = target; for (var i:int = 0; i&lt;level.length; i++) { curr=curr&#x5B;level&#x5B;i]]; } return curr; } trace(dotSyntax(this, &quot;stage.stageWidth&quot;)); trace(dotSyntax(this, &quot;graphics&quot;)); trace(dotSyntax(this, &quot;root.loaderInfo.bytesTotal&quot;)); \/*outputs something like: 800 &#x5B;object Graphics] 1230 *\/ This snippet shows how to parse dot syntax from a string. It does this by splitting the string [&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,20,21],"tags":[3,14,4],"class_list":["post-324","post","type-post","status-publish","format-standard","hentry","category-dynamic","category-string-manipulation","category-strings","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/324","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=324"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/324\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}