4 Replies Latest reply on Jun 22, 2006 3:24 AM by grahamdeuchar

    Mouse-hold button

    grahamdeuchar
      Hey guys,

      This is such a stupid question to be asking but it's one I've not come across in a while and I'm danged if I can remember how to do it - I basically have a scrollable map I've been building, but the scroll buttons need to be clicked over and over to move around the map - how can I go about having the following iterate indefinitely until the mouse is relased?:

      on(release) {
      _level0.map._x = _level0.map._x + 20;
      }

      I know it'll be an onpress do while etc etc - but I don't know the most efficient way of tackling it! Any ideas?

      Thanks,
      Graham
        • 1. Re: Mouse-hold button
          Sivakanesh
          This should get you on the right tracks.
          First setup a variable called Zoom set it to true on onMouseDown and false onMouseUp.
          Then
          this.onEnterFrame = function() {
          if (Zoom) {
          //code for zooming;
          }

          if you wanted to stop the frame looping use this.onEnterFrame = null;
          • 2. Re: Mouse-hold button
            grahamdeuchar Level 1
            Sorry. I'm still bamboozled here - I'm going totally the wrong way about it I think. Here's what I have, which does virtually nothing - it works once on click but no hold-down functionality....

            onClipEvent(enterFrame) {
            var move=false;
            function left() {
            if(move==true) { _level0.map._x = _level0.map._x + 20; }
            }
            setInterval(left, 100);
            }

            onClipEvent(mouseDown) { move=true; }
            onClipEvent(mouseUp) { move=false; }
            • 3. Re: Mouse-hold button
              Tolk Level 1
              onClipEvent(enterFrame) {
              if(move) {
              _level0.map._x = _level0.map._x + 20;
              }
              }

              onClipEvent(mouseDown) { move=true; }
              onClipEvent(mouseUp) { move=false; }

              I think that's what your trying to do, like Sivakanesh said but iv'e done it for you.
              • 4. Re: Mouse-hold button
                grahamdeuchar Level 1
                Got it! Thanks guys - I've been thrown in at the deep end here being a fairly amateur ActionScripter - so much for my boss' theory that a PHP developer will automatically be a Flash guru :P