1 Reply Latest reply on Mar 6, 2009 12:08 PM by pares101

    Image Pan _ Rubber band effect

    pares101
      I am trying to make the black square do the rubber band effect while the image pans left to right with mouse movement

      Each code works seperatly but when i put them together they do not work

      here is layer 1 the code for the image pan

      this.onMouseMove = function() {
      constrainedMove(bg_mc, 4, 1);
      };
      function constrainedMove(target:MovieClip, speed:Number, dir:Number) {
      var mousePercent:Number = _xmouse/Stage.width;
      var mSpeed:Number;
      if (dir == 1) {
      mSpeed = 1-mousePercent;
      } else { mSpeed = mousePercent;
      }
      target.destX = Math.round(-((target._width-Stage.width)*mSpeed));
      target.onEnterFrame = function() {
      if (target._x == target.destX) {
      delete target.onEnterFrame;
      } else if (target._x>target.destX) {
      target._x -= Math.ceil((target._x-target.destX)*(speed/100));
      } else if (target._x<target.destX) {
      target._x += Math.ceil((target.destX-target._x)*(speed/100));
      }
      };
      }


      here is the code for the movieclip on layer 2

      MovieClip.prototype.move = function (centerx, centery, inertia, k) { x = -this._x+centerx;y = -this._y+centery;xp = xp*inertia+x*k;yp = yp*inertia+y*k;_x += xp;_y += yp;};

      now the code for the actual squarebox

      onClipEvent (enterFrame) {
      this.move(x=247.5, y=300, 0.80, 0.1);
      }


      What am i doing wrong????

      the link to my fla is here

      www.jetsetbrasil.com/imagepan_final.fla


      PLEASE HELP!