Sunday, 5 February 2012

New mouse features in FP11

In Flash Player 11.2 there are some new features added to the mouse. Firstly, the right and the middle click events are no longer native to Adobe Air - you can use them inside the Flash Player now. Here are examples of these events. When the right click event is registered the default context menu will not show up which will allow you to create your own context menu.

stage.addEventListener(MouseEvent.RIGHT_CLICK, rightHandler);

function rightHandler(e:MouseEvent):void
{
 trace(‘right mouse clicked’)
}  

stage.addEventListener(MouseEvent.MIDDLE_CLICK, middleHandler);

function middleHandler(e:MouseEvent):void
{
 trace(‘middle mouse clicked’)
}  

Mouse Lock is another feature added in FP11.2 that locks the mouse in the Flash content, so you can move the mouse infinitely in any direction. This feature can only be used in Full screen mode though.

stage.displayState = StageDisplayState.FULL_SCREEN;
stage.mouseLock = true;
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
 
 
function onMouseMove(event:MouseEvent):void
{
 if(stage.displayState == StageDisplayState.FULL_SCREEN){
  
 }
}

Lastly, there are two new properties for the MouseEvent: movementX and movementY which work when mouse locking is enabled. These properties give you the change in X or Y position based on the last mouse event.

0 comments:

  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP