{"id":495,"date":"2010-03-15T17:35:55","date_gmt":"2010-03-16T00:35:55","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2837"},"modified":"2010-03-15T17:35:55","modified_gmt":"2010-03-16T00:35:55","slug":"nonsense-clocks","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=495","title":{"rendered":"Nonsense Clocks"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n&#x5B;SWF(width = 500, height=500, backgroundColor=0x000000)]\r\n\r\nvar clockNum:int = 100;\r\nvar clocks:Vector.&lt;Function&gt; = new Vector.&lt;Function&gt;(clockNum, true);\r\n\r\nvar clockContainer:Sprite = Sprite(addChild(new Sprite()));\r\nclockContainer.x = stage.stageWidth \/ 2;\r\nclockContainer.y = stage.stageHeight \/ 2;\r\nbuildClocks();\r\nrunClocks();\r\n\r\nfunction buildClocks():void{\r\n\tfor (var i:int = 0; i&lt;clockNum; i++){\r\n\t\tvar theta:Number = Math.random() * Math.PI * 2;\r\n\t\tvar radius:Number = Math.random() * 200;\r\n\t\tvar xp:Number = radius * Math.cos(theta);\r\n\t\tvar yp:Number = radius * Math.sin(theta);\r\n\t\tclocks&#x5B;i] = makeClock(xp,yp,Math.random() * Math.PI * 2);\r\n\t}\r\n}\r\nfunction runClocks():void{\r\n\taddEventListener(Event.ENTER_FRAME, onRunClocks);\r\n}\r\nfunction onRunClocks(evt:Event):void{\r\n\tfor (var i:int = 0; i&lt;clockNum; i++){\r\n\t\tclocks&#x5B;i]();\r\n\t}\r\n\tclockContainer.rotationX = clockContainer.mouseY \/ 30;\r\n\tclockContainer.rotationY = -clockContainer.mouseX \/ 30;\r\n}\r\nfunction makeClock(x:Number, y:Number, time:Number=0):Function{\r\n\tvar radius:Number = Math.random() * 20 + 5;\r\n\tvar border:Number = radius * 0.2;\r\n\tvar smallRadius:Number = radius - radius * 0.3;\r\n\t\r\n\tvar clock:Sprite = Sprite(clockContainer.addChild(new Sprite()));\r\n\tclock.x = x;\r\n\tclock.y = y;\r\n\tclock.z = 100 - Math.random() * 200;\r\n\tclock.rotationX = Math.random() * 40 - 20;\r\n\tclock.rotationY = Math.random() * 40 - 20;\r\n\tclock.rotationZ = Math.random() * 360;\r\n\treturn function():void{\r\n\t\twith (clock.graphics){\r\n\t\t\tclear(); \r\n\t\t\tlineStyle(1,0xFFFFFF); \r\n\t\t\tdrawCircle(0,0,radius + border);\r\n\t\t\tvar xp:Number = smallRadius * Math.cos(time\/2);\r\n\t\t\tvar yp:Number = smallRadius * Math.sin(time\/2);\r\n\t\t\tmoveTo(0,0);\r\n\t\t\tlineTo(xp, yp);\r\n\t\t\txp = radius * Math.cos(time);\r\n\t\t\typ = radius * Math.sin(time);\r\n\t\t\tmoveTo(0,0);\r\n\t\t\tlineTo(xp, yp);\r\n\t\t}\r\n\t\ttime+=0.1;\r\n\t}\r\n}\r\n<\/pre>\n<p><a href=\"http:\/\/wonderfl.net\/code\/2086099fc6b4ec918e14d5cbc972371605b05c55\" target=\"blank\"\/><br \/>\nYou can go check the swf out at wonderfl.net&#8230;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/clocks.jpg\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x5B;SWF(width = 500, height=500, backgroundColor=0x000000)] var clockNum:int = 100; var clocks:Vector.&lt;Function&gt; = new Vector.&lt;Function&gt;(clockNum, true); var clockContainer:Sprite = Sprite(addChild(new Sprite())); clockContainer.x = stage.stageWidth \/ 2; clockContainer.y = stage.stageHeight \/ 2; buildClocks(); runClocks(); function buildClocks():void{ for (var i:int = 0; i&lt;clockNum; i++){ var theta:Number = Math.random() * Math.PI * 2; var radius:Number = Math.random() * 200; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101,33,94,13],"tags":[3,14,4],"class_list":["post-495","post","type-post","status-publish","format-standard","hentry","category-3d","category-graphics","category-misc","category-motion","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/495","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=495"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/495\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}