{"id":113,"date":"2008-12-04T00:00:11","date_gmt":"2008-12-04T07:00:11","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=274"},"modified":"2008-12-04T00:00:11","modified_gmt":"2008-12-04T07:00:11","slug":"format-phone","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=113","title":{"rendered":"Format Phone #"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar phoneField:TextField = new TextField();\r\nwith (phoneField) {\r\n\ttype=TextFieldType.INPUT;\r\n\tmaxChars=12;\r\n\trestrict=&quot;0-9&quot;;\r\n\tborder=true;\r\n\twidth=100;\r\n\theight=20;\r\n\tx=y=20;\r\n}\r\naddChild(phoneField);\r\n\r\nphoneField.addEventListener(TextEvent.TEXT_INPUT, onInput);\r\n\r\nfunction onInput(evt:TextEvent):void {\r\n\tif (phoneField.length==3 || phoneField.length==7) {\r\n\t\tphoneField.appendText(&quot;-&quot;);\r\n\t\tvar leng:int=phoneField.text.length;\r\n\t\tphoneField.setSelection(leng, leng);\r\n\t}\r\n}\r\n<\/pre>\n<p>Quick way to make sure text input is formatted like a phone number.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>var phoneField:TextField = new TextField(); with (phoneField) { type=TextFieldType.INPUT; maxChars=12; restrict=&quot;0-9&quot;; border=true; width=100; height=20; x=y=20; } addChild(phoneField); phoneField.addEventListener(TextEvent.TEXT_INPUT, onInput); function onInput(evt:TextEvent):void { if (phoneField.length==3 || phoneField.length==7) { phoneField.appendText(&quot;-&quot;); var leng:int=phoneField.text.length; phoneField.setSelection(leng, leng); } } Quick way to make sure text input is formatted like a phone number.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[3,4,84],"class_list":["post-113","post","type-post","status-publish","format-standard","hentry","category-string-manipulation","tag-actionscript","tag-flash","tag-phone-number"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/113","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=113"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/113\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}