A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: ASe how to click-and-drag solution and question

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

    ASe how to click-and-drag solution and question

    I finally found an AS3 code that will allow me to scroll through a series of images by clicking and dragging left or right.
    the link to this code is this

    http://services.communitymx.com/cont...0CA&print=true

    like i said this code allows you to drag left-right.
    i have managed to switch to drag up-down,

    MY QUESTION IS: IS THERE A WAY TO DRAG BOTH LEFT-RIGHT, AND UP-DOWN?
    i don't mean rotate the image up and down, i mean have it rotate as it is (left to right), but be able to drag the mouse up or to the right, to make it rotate right, or drag the mouse down and to the left, to make it rotate left.
    right now when you drag the mouse up or down, nothing happens. so to clarify, i'm saying be able to drag left-right-up-down and it will still rotate

    here is the code you'll find at that link...

    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);
      }
    }
    Last edited by mattwatts15; 10-28-2009 at 09:24 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