{"id":452,"date":"2009-12-30T16:48:58","date_gmt":"2009-12-30T23:48:58","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2536"},"modified":"2009-12-30T16:48:58","modified_gmt":"2009-12-30T23:48:58","slug":"rotation-property-weirdness","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=452","title":{"rendered":"Rotation Property Weirdness"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar boxA:Shape = Shape(addChild(new Shape()));\r\nwith (boxA.graphics) beginFill(0), drawRect(-10,-10,20,20);\r\n\r\nvar boxB:Shape = Shape(addChild(new Shape()));\r\nwith (boxB.graphics) beginFill(0), drawRect(-10,-10,20,20);\r\n\r\nboxA.x = 100; \r\nboxA.y = 100;\r\n\r\nboxB.x = 200; \r\nboxB.y = 100;\r\n\r\nvar rot:Number = 32750;\r\n\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n  rot += 1\r\n  \/\/ will stop rotating \r\n  boxA.rotation = rot\r\n  \/\/ will keep rotating\r\n  boxB.rotation = rot % 360;\r\n}\r\n<\/pre>\n<p>I recently became aware of a strange aspect of the rotation property on DisplayObjects. For some reason, once it&#8217;s value goes a little beyond ~32750 the DisplayObject will simply stop rotating. If you read the rotation property it is still changing, but there is no visual update &#8211; a quick check on the DisplayObject.transform.matrix property will show that the value has stopped. <\/p>\n<p>The easy fix is to use mod before applying the value to the rotation property. Surprised I&#8217;ve never come across this one before. Maybe someone can shed some light on this.<\/p>\n<p><em><br \/>\n\/\/ for people searching google for solutions to this problem I&#8217;ll add the following key words:<br \/>\nMovieClip stops rotating, DisplayObject stops rotating, rotation property broken, not rotating<br \/>\n<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>var boxA:Shape = Shape(addChild(new Shape())); with (boxA.graphics) beginFill(0), drawRect(-10,-10,20,20); var boxB:Shape = Shape(addChild(new Shape())); with (boxB.graphics) beginFill(0), drawRect(-10,-10,20,20); boxA.x = 100; boxA.y = 100; boxB.x = 200; boxB.y = 100; var rot:Number = 32750; addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { rot += 1 \/\/ will stop rotating boxA.rotation = rot \/\/ will keep rotating boxB.rotation = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,94,13],"tags":[3,14,4],"class_list":["post-452","post","type-post","status-publish","format-standard","hentry","category-displayobject","category-misc","category-motion","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/452","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=452"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/452\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}