A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: click-and-drag rotating images

Threaded View

  1. #1
    Senior Member
    Join Date
    Oct 2009
    Posts
    112

    click-and-drag rotating images

    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 :


    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...
    Last edited by mattwatts15; 11-11-2009 at 05:58 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center