FORUMS: list search recent posts

click-and-drag rotating object

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
matt watts
click-and-drag rotating object
on Nov 11, 2009 at 9:43:39 am

I built one of those click-and-drag rotating images. basically you click on it and drag left to right and it will scroll through a series of images in the timeline to make it appear like the object in the images is rotating

the problem is I want to be able to click-and-drag the mouse up-and-down, AND left-and-right. Right now I can program it to do one or the other, but not both. if i put left,right,up,AND down in the code it ignores one or the other.

any ideas?
heres the code :


photos.stop();

var startX:Number;
var startY: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;
startY = photos.mouseY;
startFrame = photos.currentFrame;
stage.addEventListener(MouseEvent.MOUSE_MOVE,
moveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP,
releaseHandler);
}

function releaseHandler(evt:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE,
moveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP,
releaseHandler);
}

function moveHandler(evt:MouseEvent):void {

changeDistance = Math.round((photos.mouseX
- startX)/30);
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);
}
}

right now (with this code) it will click and drag left to right only...


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]