Cancel function on mouse up?
<p>I am wondering how do i cancel/stop a function upon a mouse up event? </p>

<p>I basically have a onmousedown followed by a mousemove this lets me find a way to work out the offset amount with the mouse, but if i mouseup - it still keeps following the mouse!</p>

<p>I use:</p>

<pre><code>function mousePos(e){  //gets the mouse position on click "start position"
    mousex = e.pageX;
    mousey = e.pageY;
canvas.addEventListener("mousemove", movePos, false);
}

function movePos(e){ // works out how far the mouse has moved from start position
    offset_x = mousex - e.pageX;
    offset_y = mousey - e.pageY;
}

//this is in my init function for body onload
canvas.addEventListener("mousedown", mousePos, false);
</code></pre>

<p>The problem i have is i need it to stop running once the button is no longer pressed. </p>
