1 Reply Latest reply on Nov 17, 2006 2:36 PM by Newsgroup_User

    Slider Jumping

    ich_kann_schnell_laufen

      I have a slider that is hopping and i can't figure why. The window is 700px wide. Here is the AS and the error. Any help would be greatly appreciated. Thanks.


      onClipEvent (load) {
      nScreenWidth = 700;
      nMaxRate = 15;
      // nPixels determines the speed of the slider movement
      function moveLeft(nPixels) {
      this._x -= nPixels;
      if (this._x<0-nScreenWidth) {
      this._x = 0;
      }
      }
      function moveRight(nPixels) {
      this._x += nPixels;
      if (this._x>0) {
      this._x = 0-nScreenWidth;
      }
      }
      }
      onClipEvent (enterFrame) {
      // move slider with speed dependent on mouse position
      if (_root._xmouse<nScreenWidth/2 && _root._xmouse>0) {
      moveRight(nMaxRate-_root._xmouse*nMaxRate/(nScreenWidth/2));
      } else {
      if (_root._xmouse>nScreenWidth/2 && _root._xmouse<nScreenWidth) {
      moveLeft(_root._xmouse*nMaxRate/(nScreenWidth/2)-nMaxRate);
      }
      }
      }

      Error:

      Scene=Scene 1, Layer=actions, Frame=2: Line 1: Clip events are permitted only for movie clip instances
      onClipEvent (load) {

      Scene=Scene 1, Layer=actions, Frame=2: Line 18: Clip events are permitted only for movie clip instances
      onClipEvent (enterFrame) {
        • 1. Re: Slider Jumping
          Level 7
          First your onClipEvent statements have to be on the movieclips and not on
          the timeline (select the movieclip first before to edit the actions, or
          check at the bottom of the action window that it's an mc and not a frame).

          Then I'm not sure how it is supposed to behave because I don't know if it's
          inside an mc or not, and the location of the registration vis a vis of your
          _root. However, in moveRight, you are saying, if _x of my mc is greater than
          0 go to -700.

          That might be the jump...

          JG

          "ich_kann_schnell_laufen" <webforumsuser@macromedia.com> wrote in message
          news:ejl30t$rck$1@forums.macromedia.com...
          >
          > I have a slider that is hopping and i can't figure why. The window is
          > 700px
          > wide. Here is the AS and the error. Any help would be greatly appreciated.
          > Thanks.
          >
          >
          > onClipEvent (load) {
          > nScreenWidth = 700;
          > nMaxRate = 15;
          > // nPixels determines the speed of the slider movement
          > function moveLeft(nPixels) {
          > this._x -= nPixels;
          > if (this._x<0-nScreenWidth) {
          > this._x = 0;
          > }
          > }
          > function moveRight(nPixels) {
          > this._x += nPixels;
          > if (this._x>0) {
          > this._x = 0-nScreenWidth;
          > }
          > }
          > }
          > onClipEvent (enterFrame) {
          > // move slider with speed dependent on mouse position
          > if (_root._xmouse<nScreenWidth/2 && _root._xmouse>0) {
          > moveRight(nMaxRate-_root._xmouse*nMaxRate/(nScreenWidth/2));
          > } else {
          > if (_root._xmouse>nScreenWidth/2 && _root._xmouse<nScreenWidth) {
          > moveLeft(_root._xmouse*nMaxRate/(nScreenWidth/2)-nMaxRate);
          > }
          > }
          > }
          >
          > Error:
          >
          > Scene=Scene 1, Layer=actions, Frame=2: Line 1: Clip events are permitted
          > only
          > for movie clip instances
          > onClipEvent (load) {
          >
          > Scene=Scene 1, Layer=actions, Frame=2: Line 18: Clip events are permitted
          > only
          > for movie clip instances
          > onClipEvent (enterFrame) {
          >
          >