Using MouseLock, Right Click, Middle Click features in Flash Player 11.2
February 22nd, 2012
Flash Player 11.2 introduces new mouse features designed for game developers in mind, but many other developers can find them useful as well.
Demo
Try this technical demo using the new features, you need Flash Player 11.2 installed (download here).
http://flashrealtime.com/demos/newmousefeatures/

* Double click for fullscreen to enable mouseLock. Try also right click, middle click, click and mouse wheel.
The demo source code is available here: http://flashrealtime.com/demos/newmousefeatures/NewMouseFeatures.as
Mouse Lock
Locks the mouse in the center of the screen, gives you a relative position of the mouse (movementX, movementY), FULLSCREEN mode only. Mouse Lock is very powerful feature especially in first-person-shooter or third-person-shooter games as it allows you to move freely without reaching the screen boundaries.
New API:
- stage.mouseLock
- mouseEvent.movementX
- mouseEvent.movementY
private function startMouseLock():void{ // go fullscreen stage.displayState = StageDisplayState.FULL_SCREEN; // activate mouseLock stage.mouseLock = true; // register event listener stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); } protected function onMouseMove(event:MouseEvent):void { if(stage.displayState == StageDisplayState.FULL_SCREEN){ // movementX and movementY contain mouseLock delta positions trace("movementX: "+event.movementX + " - movementY: " + event.movementY); } }
Right Click
Right click allows you to display your own context menu or in terms of first-person-shooter use another weapon or action, like throw a flare. The nice side-effect is that by registering right click on stage, you can get rid of the default “About Flash Player” context menu.
The usage is simple, like with standard CLICK:
// register right click listener stage.addEventListener(MouseEvent.RIGHT_CLICK, onRightClickNow); // ... // the event listener itself protected function onRightClickNow(event:MouseEvent):void { trace("right click"); }
Middle Click
Same approach as Right Click, just register MouseEvent.MIDDLE_CLICK event.
stage.addEventListener(MouseEvent.MIDDLE_CLICK, onMiddleClick);
Setting up the Flash Builder
To access the new features you need to link new playerglobal.swc (download here) in you Flash Builder project. See screenshot:
You also need to set -swf-version=15 in ActionScript compiler settings. See screenshot:

MAX Racer Remote Device Controller in AIR for Android
November 25th, 2010
Quick heads-up my friends. When we first demoed MAX Racer, we have previewed initial support for USB Steering Wheel, etc. This support is a sneak peek feature in Flash Player, not available right now.
This really needs you have one of these devices at home. So we were thinking about more lightweight way of controlling the game and device or mobile phone is ideal for this.
I’ve built a little app in Flex Mobile “Hero” for AIR for Android, that controls the game by sending accelerometer, speed info, brake and so on using local P2P connection over WIFI.
Check the video how it works:
Read the rest of this entry »
P2P Gaming Libs from my MAX 2010 session
November 24th, 2010
Update 3/18/2011: Source-code is available here: https://github.com/tomkrcha/RealtimeGameLib
Update 11/28/2010: Library now accepts variable group name, so you can create more instances. Download updated library below. Example: var game:P2PGame = new P2PGame(serverAddress,groupName);
Lot of you guys are asking for libs I’ve used in my Adobe MAX 2010 session Building P2P Multiplayer Games.
It’s still work in progress, but you can basically grab SWC libraries here with example.
I don’t want to publish source now as it needs several changes, refactor, comments, etc. But source-code should be available soon
This library has been used for MAX Racer without no change. So it’s kickass tested stuff! But not completely finished and documented yet. So this is the disclaimer, I do not provide any guarantees.
If you want to start playing with it, go ahead. Comments are highly welcome!
This engines creates a full mesh network via DIRECT_CONNECTIONS NetStreams among all connected users. Thanks to that, you get lowest latency possible and it’s highly suitable for realtime gaming.
Android Dev: Resolving Empty List Of Devices Attached via USB Debugging on Windows
November 16th, 2010
This is useful tip for Android developers on Windows, especially if you are AIR for Android developer and use Flash Builder or Flash Professional and want to debug and test your apps on mobile phone via USB. On Mac I didn’t have any problem, I just plugged device via USB and it has started working. On Windows it’s a little more tricky. It’s missing driver problem.
First, you install Android SDK.
And when you connect your Android device via USB – it can happen that you see empty list of devices by calling: adb devices command available in android-sdk/tools folder.
Resolving “NetGroup.Connect.Rejected” or when your Flash P2P apps stop working
November 2nd, 2010
I just ran into a problem with NetGroup.Connect.Rejected, my FMS4 server was running ok – I have even tried Cirrus/Stratus and I was still getting this error on demos, which were properly working before.
OK – so what is this error about?
It’s all about your Flash Player security and it’s basically telling you that you have denied access to some source. This happens, when you start developing apps on different PC and someone before you denied to use P2P or similar.
Solution:
1. Go to Global Settings

2. delete all or specific P2P settings in Global Settings

3. run your application again (it should be in browser, had sometimes problems with standalone apps, where dialog didn’t appear)
this dialog should appear. Click Allow and better Remember.

Don’t forget that these settings are inherited to all versions of Flash Player you have on your PC, even to betas or prereleases.
Good Luck!


