Quick Tip: Menu Mouse Lock with Scaleform + UDK

Lately, our team has been putting work into polishing the menus for our upcoming game, Super Slash n'Grab.

One of the outstanding issues with our current implementation was that users could accidentally cause button focus to go wrong by clicking the mouse, even though our mouse was not enabled for input in either UnrealScript or AS3.

It took about an hour of searching through Scaleform's documentation, I found an AS3 function that, in combination with regular AS3 functionality, fixed the issue for us.

If you're in a similar situation, try using this code:

Source file
 1 import scaleform.clik.core.CLIK;
 3 CLIK.disableNullFocusMoves = true;
 4 CLIK.stage.mouseEnabled = false;
 5 CLIK.stage.mouseChildren = false;

How does this code work?

CLIK.stage is where Scaleform stores its reference to the main flash stage.

By setting mouseEnabled and mouseChildren to false, the mouse position in flash can no longer be changed by mouse inputs. I am not sure where the default location is, but I know that it is offscreen.

CLIK.disableNullFocusMoves tells the scaleform focus handler to ignore requests to set focus to null. Since the pointer is offscreen, it's pointing to a null object, and thus the focus events set by its clicks are ignored.

Let me know in the comments how this trick works out for you.