{"id":196,"date":"2009-02-20T09:21:28","date_gmt":"2009-02-20T16:21:28","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=817"},"modified":"2009-02-20T09:21:28","modified_gmt":"2009-02-20T16:21:28","slug":"stage-grid","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=196","title":{"rendered":"Stage Grid"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n\/\/ try changing the size of  the stage\r\n&#x5B;SWF(width = 600, height = 400)]\r\n\r\n\/\/ try changing the tile size (make sure swf width and height are evenly divisible by this number)\r\nvar tileSize:int = 20;\r\n\r\n\r\nvar cols:int = stage.stageWidth \/ tileSize;\r\nvar rows:int = stage.stageHeight \/ tileSize;\r\n\r\nvar grid:Sprite = Sprite(addChild(new Sprite()));\r\ngrid.graphics.lineStyle(0,0x000000);\r\n\r\nvar i:int = 0;\r\n\r\nfor (i = 1; i&lt;cols; i++){\r\n\tvar posX:Number = i * tileSize\r\n\tgrid.graphics.moveTo(posX, 0);\r\n\tgrid.graphics.lineTo(posX, stage.stageHeight);\r\n}\r\nfor (i = 1; i&lt;rows; i++){\r\n\tvar posY:Number = i * tileSize\r\n\tgrid.graphics.moveTo(0, posY);\r\n\tgrid.graphics.lineTo(stage.stageWidth, posY);\r\n}\r\n<\/pre>\n<p>This is a quick way to fill the stage with a grid. I like my grids to have square tiles with sizes like 5&#215;5, 10&#215;10 20&#215;20 etc&#8230;. So as long as you make sure that you&#8217;re swf width and height are evenly divisible by your tileSize, this snippet will work nicely.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ try changing the size of the stage &#x5B;SWF(width = 600, height = 400)] \/\/ try changing the tile size (make sure swf width and height are evenly divisible by this number) var tileSize:int = 20; var cols:int = stage.stageWidth \/ tileSize; var rows:int = stage.stageHeight \/ tileSize; var grid:Sprite = Sprite(addChild(new Sprite())); grid.graphics.lineStyle(0,0&#215;000000); var [&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":[3,4],"class_list":["post-196","post","type-post","status-publish","format-standard","hentry","category-graphics","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/196","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=196"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/196\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}