Pittsburgh Web Development | DVD Authoring Services | Web Hosting    

Pittsburgh Web Development | DVD Authoring Services
 
Contact Me
 
 
Action Script - Two Way Scrolling Movie Clips

I will let you figure how this one works on your own. The first two scripts should be placed on movie clip to be scrolled ("scrollingMovie".) Speed is the number of pixels per frame that the clip scrolls. Destination is the x value were it will stop. Set the Destination to the the initial point. "damperRange" is how close to the destination the scrolling will get before it begins to slow down. Place the remaining scripts on the frame. Fill in the name of the left scroll and right scroll buttons as well as the far left and far right x coordinates. Now when on of the buttons is rolled over, your movie clip will scroll back and forth. It will stop when the button is rolled off.

onClipEvent (load) {
var C = 1
var step = 1
var damper = 4
_root.damperRange = ?
_root.Direction =0
_root.Speed =?
_root.Destination =?
}

onClipEvent (enterFrame) {
if ((_root.Destination + _root.damperRange) >= _x && _x >=(_root.Destination -_root.damperRange)) {
_x += (_root.Destination-_x)/damper;
C = 1
} else {
_x +=_root.Direction *_root.Speed * (1 - (1/C))
C = C + 1
}

rightScrollButtonName.onRollOver = function () {
_root.Direction = -1
_root.Destination = FarRightx
}

rightScrollButtonName.onRollOut = function () {
_root.Destination = scrollingMovie._x
}

leftScrollButtonName.onRollOver = function () {
_root.Direction = 1
_root.Destination = FarLeftx
}

leftScrollButtonName.onRollOut = function () {
_root.Destination = scrollingMovie._x
}