{"id":709,"date":"2012-09-05T07:00:14","date_gmt":"2012-09-05T11:00:14","guid":{"rendered":"http:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/?p=709"},"modified":"2012-08-31T12:33:20","modified_gmt":"2012-08-31T16:33:20","slug":"hiding-the-mouse-in-flash","status":"publish","type":"post","link":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/2012\/09\/hiding-the-mouse-in-flash\/","title":{"rendered":"Hiding the Mouse in Flash"},"content":{"rendered":"<p>Hiding the mouse in a Flash app should be a simple matter of calling flash.ui.Mouse.hide(). \u00a0This works totally fine in the standalone player.<\/p>\n<p>However, in some browsers that doesn&#8217;t actually hide the mouse all the time. \u00a0For example, this has been a problem off and on in Chrome\/Chromium for some time on <a href=\"http:\/\/code.google.com\/p\/chromium\/issues\/detail?id=32703\">various platforms<\/a>. \u00a0In Linux under Chromium (build\u00a020.0.1132.57), I could not figure out any real pattern to making it hide or not using just flash.ui.Mouse.hide(). \u00a0Sometimes it works, sometimes it doesn&#8217;t. \u00a0You see this a lot in Flash games that show a custom display list cursor under the native system cursor; the latter didn&#8217;t hide properly.<\/p>\n<p>Fortunately, assuming you&#8217;re using Flash &gt;= 10.2, there is a seemingly reliable workaround. \u00a0Set the mouse cursor to the default cursor (!), then hide the mouse like usual. \u00a0E.g., in Haxe\/NME:<\/p>\n<pre>  nme.ui.Mouse.cursor = flash.ui.MouseCursor.AUTO;\r\n  nme.ui.Mouse.hide();<\/pre>\n<p>Note that MouseCursor isn&#8217;t wrapped by NME so you need to refer directly to the Flash classpath, and it only works for the flash target.<\/p>\n<p>Setting Mouse.cursor triggers Flash&#8217;s native cursor support. Presumably doing that is in turn changing some interaction or state between Flash and the browser, such that Mouse.hide() seems to actually reliably hide the mouse.<\/p>\n<p>In <a href=\"rocketshipgames.com\/tools\/rockethaxe\/\">RocketHaxe<\/a> this happens automatically on the Flash platform, e.g., by calling com.rocketshipgames.haxe.ui.Mouse.disable().<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hiding the mouse in a Flash app should be a simple matter of calling flash.ui.Mouse.hide(). \u00a0This works totally fine in the standalone player. However, in some browsers that doesn&#8217;t actually hide the mouse all the time. \u00a0For example, this has been a problem off and on in Chrome\/Chromium for some time on various platforms. \u00a0In &hellip; <a href=\"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/2012\/09\/hiding-the-mouse-in-flash\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[69,82,277],"class_list":["post-709","post","type-post","status-publish","format-standard","hentry","category-code","tag-flash","tag-haxe","tag-videogames"],"_links":{"self":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts\/709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/comments?post=709"}],"version-history":[{"count":2,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts\/709\/revisions"}],"predecessor-version":[{"id":711,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts\/709\/revisions\/711"}],"wp:attachment":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/media?parent=709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/categories?post=709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/tags?post=709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}