Return to Snippet

Revision: 41067
at February 11, 2011 10:19 by CammoKing


Initial Code
hiResSprite.addEventListener(MouseEvent.MOUSE_DOWN,startDragHiRes);

function startDragHiRes(e:Event):void {
    var hiResWidth = e.target.width;
    var hiResHeight = e.target.height;
    var stageWidthVal = stage.stageWidth;
    var stageHeightVal = stage.stageHeight;

    var hiResX = hiResWidth - stageWidthVal;
    var hiResY = hiResHeight - stageHeightVal;
    var dragWidth = hiResWidth - stageWidthVal;
    var dragHeight = hiResHeight - stageHeightVal;
	
    var hiResDragRect = new Rectangle(-hiResX,-hiResY,dragWidth,dragHeight);
    hiResSprite.startDrag(false,hiResDragRect);
}

Initial URL

                                

Initial Description
This function will keep an image that is larger than the stage dragging within the stage view, stopping at any edge of the image.

Initial Title
Keep Larger Image or Object draggable within stage - Actionscript

Initial Tags
actionscript

Initial Language
ActionScript 3