1 Reply Latest reply on Feb 25, 2008 9:51 PM by cmorrissey

    horizontal scrolling images

    kar13
      Hi.
      I originally posted this in the General Discussion forum, but realized it may belong here instead.
      I am trying to create a scrolling image area. The code I have now recognizes the mouse coordinates *anywhere* on the screen (not just over the scrolling area). I want the images to automatically begin scrolling to the right without user interaction, no matter where their mouse is. Currently, the images won't scroll on page load if my mouse is anywhere on the left of the screen... even if it's nowhere near the scroll area. I can see why that's happening, given the code below, but how do I get around that??

      I want to keep the functionality of the actual scrolling area as it is now when you hover your mouse in the active Flash area. For example: moving the mouse left or right scrolls the images correctly and they slow/stop when the mouse is in the center of the Flash image area. That part is fine.

      I just need some code that will initiate the images to automatically scroll slowly to the right upon page load -- no matter where the mouse is.
      Any ideas?


      Thank you!
      -Karen


      Here's the code I'm working with:


      Attach Code

      //Fill up these variables and your done
      //To make it easier to edit, the mask and the movieclip should stay on the _root
      onClipEvent (load) {
      //Total width of the whole movie stage
      nMovieWidth = 950;
      //Width of the movieclip to move (This)
      //Don't forget to put the right width after you add more thumbnails.
      nClipWidth = 1895.3;
      //_x value of the movieclip to move (Take the _root value)
      //Put the same as nMaskX and make sure your MovieClip is at this position
      nClipX = 0;
      //Max speed (FPS) of the scroll
      nMaxSpeed = 8;
      //
      //These values are related to the mask of the movieclip
      nMaskWidth = 950;
      nMaskHeight = 225;
      //_x value of the mask (Take the _root value)
      nMaskX = 0;
      //_y value of the mask (Take the _root value)
      nMaskY = 25;
      //Second _x value of the mask
      nMaskXX = (nMaskX+nMaskWidth);
      //Second _y value of the mask
      nMaskYY = (nMaskY+nMaskHeight);
      //
      //nPixels determines the speed of the slider movement
      function moveLeft(nPixels) {
      this._x -= nPixels;
      if (this._x>nMaskX) {
      this._x = nMaskX;
      }
      }
      function moveRight(nPixels) {
      this._x += nPixels;
      if (this._x<(nMaskWidth-nClipWidth+nClipX)) {
      this._x = (nMaskWidth-nClipWidth+nClipX);
      }
      }
      }
      onClipEvent (enterFrame) {
      //Move slider with speed dependent on mouse position inside the Mask coordinates
      if (_root._xmouse<(nMovieWidth/4) && _root._xmouse>nMaskX) {
      if (_root._ymouse>nMaskY && _root._ymouse<nMaskYY) {
      moveLeft(_root._xmouse*nMaxSpeed/(nMovieWidth/4)-nMaxSpeed);
      }
      } else {
      if (_root._xmouse>(nMovieWidth/2) && _root._xmouse<nMaskXX) {
      if (_root._ymouse>nMaskY && _root._ymouse<nMaskYY) {
      moveRight(nMaxSpeed-_root._xmouse*nMaxSpeed/(nMovieWidth/2));
      }
      }
      }
      }