Revision: 56952
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 26, 2012 19:47 by adrianparr
Initial Code
photos.stop(); var startX:Number; var startFrame:int; var changeDistance:int; var travelDistance:int; photos.buttonMode = true; photos.addEventListener(MouseEvent.MOUSE_DOWN, pressHandler); function pressHandler(evt:MouseEvent):void { startX = photos.mouseX; startFrame = photos.currentFrame; photos.addEventListener(MouseEvent.MOUSE_MOVE, moveHandler); stage.addEventListener(MouseEvent.MOUSE_UP, releaseHandler); } function releaseHandler(evt:MouseEvent):void { photos.removeEventListener(MouseEvent.MOUSE_MOVE, moveHandler); stage.removeEventListener(MouseEvent.MOUSE_UP, releaseHandler); } function moveHandler(evt:MouseEvent):void { changeDistance = Math.round((photos.mouseX - startX) / 10); travelDistance = startFrame + changeDistance; if (travelDistance > photos.totalFrames) { photos.gotoAndStop(travelDistance % photos.totalFrames); } else if (travelDistance < 0) { photos.gotoAndStop(photos.totalFrames + (travelDistance % photos.totalFrames)); } else { photos.gotoAndStop(travelDistance); } }
Initial URL
http://www.communitymx.com/content/article.cfm?cid=8F0CA
Initial Description
This code is taken from David Stiller's post on the CommunityMX website. All credit goes to him.
Initial Title
AS3 Click-and-Rotate Content
Initial Tags
Initial Language
ActionScript 3