{"id":389,"date":"2009-08-24T18:14:45","date_gmt":"2009-08-25T01:14:45","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2056"},"modified":"2009-08-24T18:14:45","modified_gmt":"2009-08-25T01:14:45","slug":"bitmapdata-static","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=389","title":{"rendered":"BitmapData Static"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar canvas:BitmapData = new BitmapData(500,500,false, 0x000000);\r\naddChild(new Bitmap(canvas));\r\n\r\nvar pix:Vector.&lt;uint&gt; = new Vector.&lt;uint&gt;(canvas.width * canvas.height, true);\r\n\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n\tcanvas.lock();\r\n\tvar i:int = pix.length;\r\n\twhile(--i &gt; -1){\r\n\t\tvar c:uint = uint(Math.random() * 255);\r\n\t    pix&#x5B;i] = c &lt;&lt; 16 | c &lt;&lt; 8 | c;\r\n\t}\r\n\tcanvas.setVector(canvas.rect, pix);\r\n\tcanvas.unlock();\r\n}\r\n<\/pre>\n<p>This is an easy way to fill a BitmapData Object up with a bunch of  TV-style static&#8230;. <\/p>\n<p><i>This post is meant to serve as filler while I work to get a good solid SIMPLE fp10, drawing api z-sorting example going&#8230; There seem to be 3 main ways of doing z-sorting all of which don&#8217;t seem right to me for some reason&#8230; they all work&#8230; but I have a gut feeling there is a faster way&#8230; The winner so far (unexpectedly)  is using Array.sortOn<\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>var canvas:BitmapData = new BitmapData(500,500,false, 0x000000); addChild(new Bitmap(canvas)); var pix:Vector.&lt;uint&gt; = new Vector.&lt;uint&gt;(canvas.width * canvas.height, true); addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { canvas.lock(); var i:int = pix.length; while(&#8211;i &gt; -1){ var c:uint = uint(Math.random() * 255); pix&#x5B;i] = c &lt;&lt; 16 | c &lt;&lt; 8 | c; } canvas.setVector(canvas.rect, pix); canvas.unlock(); } This is an easy [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,94,79],"tags":[3,14,4],"class_list":["post-389","post","type-post","status-publish","format-standard","hentry","category-bitmapdata","category-misc","category-vector","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/389","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=389"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/389\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}