I have a red square that I want to drag only on the x-axis. I\'ve worked out a simple script, which theoretically should work, but it\'s not behaving properly. It\'s a bit h
THIS WILL WORK ACTIONSCRIPT 3 (Semilla Sol Apps)
1- create your regular MOUSE DOWN and MOUSE UP event listeners
2- drop your 'startDrag' and 'stopDrag' elements in each function thereof respectively
HERE IS HOW TO LOCK DOWN THE AXIS:
1: create an event listener for the object you wish to restrict...in this example it's a movieclip instance named 'player':
player.addEventListener(Event.ENTER_FRAME, pLimiter);
HERE IS THE 'pLimter' FUNCTION:
function pLimiter(e:Event):void
{
player.y = stage.stageHeight;
}
So in this case we are restricting 'drag' to only the x axis.