{"id":202,"date":"2009-02-25T00:00:18","date_gmt":"2009-02-25T07:00:18","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=853"},"modified":"2009-02-25T00:00:18","modified_gmt":"2009-02-25T07:00:18","slug":"zig-zag-binary-ix2-i2","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=202","title":{"rendered":"Zig Zag Binary ix2 &#038; i\/2"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar txt:TextField = TextField(addChild(new TextField()));\r\ntxt.text = &quot;&quot;;\r\ntxt.width = 190;\r\ntxt.height = 400;\r\ntxt.multiline = true;\r\n\r\nvar count:int = 1;\r\nfunction render():void{\r\n\tvar line = int(count).toString(2);\r\n\twhile(line.length &lt; 31){\r\n\t\tline = &quot;0&quot; + line;\r\n\t}\r\n    txt.appendText(line + &quot;n&quot;);\r\n\ttxt.scrollV= txt.maxScrollV;\r\n}\r\n\r\naddEventListener(Event.ENTER_FRAME, onCountUp);\r\nfunction onCountUp(evt:Event):void {\r\n\tcount *= 2;\r\n\trender();\r\n\tif (count ==0x40000000){\r\n\t\tremoveEventListener(Event.ENTER_FRAME, onCountUp);\r\n\t\taddEventListener(Event.ENTER_FRAME, onCountDown);\r\n\t}\r\n}\r\nfunction onCountDown(evt:Event):void {\r\n\tcount \/= 2;\r\n\trender();\r\n\tif (count ==1){\r\n\t\taddEventListener(Event.ENTER_FRAME, onCountUp);\r\n\t\tremoveEventListener(Event.ENTER_FRAME, onCountDown);\r\n\t}\r\n}\r\n<\/pre>\n<p>The above animates a zig zag pattern in a TextField.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>var txt:TextField = TextField(addChild(new TextField())); txt.text = &quot;&quot;; txt.width = 190; txt.height = 400; txt.multiline = true; var count:int = 1; function render():void{ var line = int(count).toString(2); while(line.length &lt; 31){ line = &quot;0&quot; + line; } txt.appendText(line + &quot;n&quot;); txt.scrollV= txt.maxScrollV; } addEventListener(Event.ENTER_FRAME, onCountUp); function onCountUp(evt:Event):void { count *= 2; render(); if (count ==0x40000000){ removeEventListener(Event.ENTER_FRAME, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121,20,21],"tags":[],"class_list":["post-202","post","type-post","status-publish","format-standard","hentry","category-math","category-string-manipulation","category-strings"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/202","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=202"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/202\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}