Update
The bug is this line in handleMouseDown:
currentshape = new Shape();
You've used currentshape, not currentShape (with the capital S). That creates a separate and unrelated implicit global rather than updating the currentShape one, since JavaScript is case sensitive (s and S are two different variables).
To avoid this sort of problem in the future, you might consider using the strict mode offered by the latest version of JavaScript, ECMAScript 5th edition. In strict mode, amongst other things, you no longer have the horror of implicit globals. Assigning to an unresolvable reference causes an error instead.
To do that, you'd use a scoping function around all of your code, and put "use strict"; at the top of it, like this:
(function() {
"use strict";
var currentShape = new Shape();
function handleMouseDown() {
// ...
}
function handleMouseMove() {
// ...
}
// ...
})();
This is totally backward-compatible with JavaScript engines that don't support the new strict mode yet, so it doesn't cause trouble on older browsers (you just don't get the benefits of strict mode).
This also has the advantage that you're not introducing any global variables into an already-crowded global variable space. currentShape is shared by the functions inside your scoping function, but neither it nor handleMouseDown or handleMouseMove is global.
One side-effect of doing that is that functions referenced from event handlers created via onXYZ attributes in your HTML markup need to be global, and so if none of your functions is global, you can't use them anymore; you use addEventListener / attachEvent to hook up event handlers instead. That's usually a good idea anyway, but if you absolutely must use onXYZ handlers, you can do so by making selected functions globals by assigning them to properties on window, e.g. window.handleMouseMove = handleMouseMove; (live example). In general, though, best to avoid any globals at all and use the addEventListener / attachEvent (aka "DOM2" style) of event handlers.
Old answer before you posted your real code:
If the code really is as quoted, you'll create a new Shape object every time onmousemove is called.
I suspect you may have removed the code that was actually causing the problem when simplifying it to add it to your question. For instance:
var shapes = new Array();
var current = new Shape();
var foo = current; // <<==== New code
function onmousemove(e){
current = new Shape();
current.xArray.push(e.pageX, e.pageY);
......
shapes.push(current);
}
With that code, although current will be set to a new Shape on every call to onmousemove, foo will always point to the initial Shape, because there is no enduring connection between the variable foo and the variable current; current can get a new value without affecting the value held by foo.
So if your real code has something like that (passing current into a function, assigning it to another variable, or any of several other things), that would be the problem.
newkeyword results a new instance ofShape. To verify, addalert(current === new Shape)to your code (anywhere).shapesarray. Maybe you could put a demo on jsfiddle.net. Also, if you're creating (or trying to create) a newShapeevery time the mouse moves why have an array for the x and y coordinates? You don't get to store the next move in the same arrays because you (try to) create anotherShape.