Parallax

Out of context: Reply #5

  • Started
  • Last post
  • 18 Responses
  • Haydesign0

    Thanks guys here is the code for the left & right movement. I suppose its some sort of mouse out handler I need in there. But my skills are weak!

    function parallax (layer, speed)
    {
    var distance=_root._xmouse-Stage.wid...

    if (_xmouse > Stage.width/2){
    layer._x -= distance*speed;

    }else{
    layer._x += distance*-speed;
    }

    if(layer._x = layer._width/2){
    layer._x = layer._x - layer._width/2;
    }
    }

    trees_mc.onEnterFrame = function() { parallax(this, 1/15);}
    lane_mc.onEnterFrame = function() { parallax(this, 1/30); }
    city_mc.onEnterFrame = function() { parallax(this, 1/50); }
    sky_mc.onEnterFrame = function() { parallax(this, 1/70); }

View thread