0 Replies Latest reply on Feb 2, 2007 1:01 PM by

    Scrubber instead of arrow keys to control movement

      I have a "mover" function that controls the MovieClips named "dream." It is being called with:

      dream.onEnterFrame = mover;

      Right now, the up and down arrow keys are incrementing the vz value in the onEnterFrame. I'm also incrementing a variable zdepth (arbitrary) to limit how far z can zoom in and out. I'm trying to create a scrubber (instead of the arrow keys) to control the z movement of my dream movieclips. My scrubber code is:

      var scrubber:MovieClip;
      var track:MovieClip;

      scrubber.onPress = function(){
      this.startDrag(false,0,this._y,track._x + track._width,this._y);
      this.onEnterFrame = function(){
      trace(this._x);
      _parent.vz = -(16*this._x) / 300;
      trace(_parent.vz);
      }
      }

      scrubber.onRelease = function(){
      this.stopDrag();
      delete scrubber.onEnterFrame;
      }

      scrubber.onReleaseOutside = function(){
      this.stopDrag();
      delete scrubber.onEnterFrame;
      }





      my current mover function is:

      function mover():Void {
      if (zdepth < 55 && Key.isDown(Key.UP)){
      vz -= .5;
      zdepth += .5;
      trace(vz);
      }
      if(zdepth > 0 && Key.isDown(Key.DOWN))
      {
      vz += .5;
      zdepth -= .5;
      trace(vz);
      }

      vy -= gravity;
      vx *= friction;
      vy *= friction;
      vz *= friction;
      for (var i:Number=0;i<dreamarray.length;i++) {
      var dream:MovieClip = home["dreamarray" +i];
      dream.x += vx;
      dream.y += vy;
      dream.z += vz;
      if(dream.y < 50)
      {
      dream.y = 50;
      vy = 0;
      }

      if (dream.z <= -fl) {
      dream.z._visible = false;
      }
      else
      {
      dream.z._visible = true;

      var scale:Number = fl / (fl + dream.z);
      dream._xscale = dream._yscale = scale*100;
      dream._x = vpX + dream.x * scale/2;
      dream._y = vpY + dream.y * scale/2;
      //dream._x = dream.x * scale/2;
      //dream._alpha = scale * 60 + 40;
      dream.swapDepths(-dream.z);
      }
      }
      }

      The arrow keys work, but my scrubber only works in one direction. I need some help with the logic here...so the slider can be used to zoom into a set value, then zoom back out to the original value. vz values seemed to range from -16 to 16 with the arrow keys, so i tried to write a formula to create a ratio from the width of the scrubber track to those corresponding vz values.

      When the scrubber is at 0 vz=0
      When the scrubber is at 300 vz=-16

      I'm sure my mover function needs to be changed, but I could use a little help.