{"id":83,"date":"2008-11-05T07:18:10","date_gmt":"2008-11-05T14:18:10","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=132"},"modified":"2008-11-05T07:18:10","modified_gmt":"2008-11-05T14:18:10","slug":"multiple-graphics-class-calls","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=83","title":{"rendered":"Multiple Graphics Class Calls"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n\/\/ draw red circle\r\nwith (graphics) beginFill(0xFF0000), drawCircle(200,100,30);\r\n\r\n\/\/ draw 100 gray circles\r\nwith (graphics) for (var i:int = 0; i&lt;100; i++) beginFill(0x666666), drawCircle(Math.random()*200, Math.random()*200, Math.random()*10), endFill();\r\n\r\n\/\/ draw a few lines\r\nwith (graphics) lineStyle(0, 0x000000), moveTo(10,210), lineTo(20,300), lineTo(30,210), lineTo(40,300), lineTo(50,210), lineTo(60,300);\r\n<\/pre>\n<p>Sometimes it&#8217;s tedious to write lines and lines of Graphics class method calls. Using a with statement you can reduce these calls into one long (not very readable) line of code. <\/p>\n<p>More readable example:<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nwith(graphics) {\r\n\tbeginFill(0xFF0000);\r\n\tdrawRect(0,0,100,100);\r\n\tendFill();\r\n\tbeginFill(0xFFFF00);\r\n    drawRect(10,10,80,80);\r\n\tendFill();\r\n\tbeginFill(0x0000FF);\r\n\tdrawCircle(50,50,40);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ draw red circle with (graphics) beginFill(0xFF0000), drawCircle(200,100,30); \/\/ draw 100 gray circles with (graphics) for (var i:int = 0; i&lt;100; i++) beginFill(0x666666), drawCircle(Math.random()*200, Math.random()*200, Math.random()*10), endFill(); \/\/ draw a few lines with (graphics) lineStyle(0, 0x000000), moveTo(10,210), lineTo(20,300), lineTo(30,210), lineTo(40,300), lineTo(50,210), lineTo(60,300); Sometimes it&#8217;s tedious to write lines and lines of Graphics class method calls. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-83","post","type-post","status-publish","format-standard","hentry","category-graphics"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/83","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=83"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}