Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code problems scrolling picture bar

Status
Not open for further replies.

raznov

Programmer
Apr 8, 2002
110
US
I have a scrolling picture bar that is masked on the stage. the problem is that the picutre bar does not stay on the stage and loop.

I have a movie clip in the _root. it is 1520 pixel, double the size of the movie width which is 760.

This is the code on that mc....

onClipEvent(load) {
nScreenWidth = 450;
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);
}
}
}
 
Code:
onClipEvent (load) {
    nScreenWidth = 450;
    nMaxRate = 15;
    // nPixels determines the speed of the slider movement
    function moveLeft (nPixels) {
        this._x -= nPixels;
        if (this._x<0-
(this._width/2)
Code:
) {
            this._x = 0;
        }
    }
    // 
    function moveRight (nPixels) {
        this._x += nPixels;
        if (this._x>0) {
            this._x = 0-
(this._width/2)
Code:
;
        }
    }
}
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);
        }
    }
}

dave
davdesign@hotmail.com
^^^^^^^^^^^^^^^^^^^^^​
 
thanks dave, but im still having a problem. the picutre bar loops fine, but even though it is exactly 1520 pixel which is double the screen size, it jumps when it loops. I cant figure it out.

kim
 
hi kim

I'm guessing that you're trying to create the effect of the image entering one side and leaving the other?

The above code should work if you have two images of 760 width each, held side-by-side in a movie-clip which totals 1520 in width.

If you're using one image of 1520 width then the image will appear to jump (well not 'appear', it will jump).

If you don't want to use 2 images (side-by-side in a single movie-clip) I suggest you have a look at:


dave
davdesign@hotmail.com
^^^^^^^^^^^^^^^^^^^^^​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top