Somewhat advanced scroller

Hi all,

In the attached (Flash MX 2004 professional) .fla you’ll find a reasonably basic scroller that i can’t get to work properly. The advanced part of it is that the content of the MC clip that is to be scrolled up and down is filled dynamically based on the number of items it needs to display. In this demo the number is set but this will eventually be data from an XML file. the trouble is that altough the MC scrolls one screen at a time (using setinterval and an easing function) it loses track of the correct start and end positions after one or two screens. Please take a look and see what the trouble could be. Don’t mind the design (there isn’t any) it’s just a test of the functionality. This little code snippet shows how i did the down button for instance:


function slide(clip:MovieClip, target:Number, dir:String) {
	var easeSpeed = 5;
	var id;
	if (dir == 'up') {
		clearInterval(id);
		id = setInterval(function () {
			clip._y += (target-clip._y)/easeSpeed;
		}, 60);
	}
	if (dir == 'down') {
		clearInterval(id);
		id = setInterval(function () {
			clip._y += (target-clip._y)/easeSpeed;
		}, 60);
	}
}

btnDown.onRollOver = function() {
	if (pos<(maxPos-1)) {
		pos++;
		target -= screen;
		trace(target);
		slide(myHolder, target, 'down');
	}
};