Moving a movie clip when a button is held down

I have two buttons in my movie that move a movie clip up and down on my stage. the code in the buttons atm is as follows,

[FONT=Courier New]on ([COLOR=darkorchid]press[/COLOR]){
[COLOR=darkorchid]if[/COLOR] ([COLOR=darkorchid]this[/COLOR].pics1._y<-240) {
} [COLOR=darkorchid]else[/COLOR] {
[COLOR=darkorchid]this[/COLOR].pics1._y = ([COLOR=darkorchid]this[/COLOR].pics1._y-10);
}[/FONT]

(this is just the down button)

This just checks to see if the movie clip has reached its lowest position and if it hasn’t it movies it down by 10px.

What i would like to do it make is so when the button is clicked and held the movie clip moves down untill the button is released.

How could i do this?
(Im using Flash 8 with Actionscript 2)

First, remember that if you want the clip to move down, you have to increase the _y, not decrease it.

What you’re missing, is time. I’ve attached an example using onEnterFrame. There are smarter ways to do this, but I think this is easiest to understand.

or, name the two buttons
up, and down

then


up.onPress=function () {
	moveIt(-5, 10);
}, down.onPress=function () {
	moveIt(5, 200);
};
function moveIt(dir, maxPoint) {
	pics1.onEnterFrame = function() {
		if ((dir<0 ? this._y>maxPoint : this._y<maxPoint)) {
			this._y += dir;
		}
	};
}
button.onReleaseOutside = button.onRelease=function () {
	delete _root.pics1.onEnterFrame;
};

:thumb:

Thanks that did the job :smiley: