/ Published in: ActionScript 3

This function will keep an image that is larger than the stage dragging within the stage view, stopping at any edge of the image.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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); }
Comments
