What is the difference?

Well I was making one of these smooth slidebars.
First I applied this code to time line:

function(targetx, speed) {
currentpos = this._x;
this._x += (targetx-currentpos)/speed;
};

and this to buttons:
on (rollover) {
_root.bar.move (0, 5);
}

AND ??? It didnt work out.
Then with spending sometime in the flash help I found and applied this:

MovieClip.prototype.move = function(targetx, speed) {
this.onEnterFrame = function() {
currentpos = this._x;
this._x += (targetx-currentpos)/speed;
};
};

but I dont know why I did it like that.
Can anyone please explain me the exact difference between those 2 and this prototype stuff ?
Thanks