Change/draw polyline on mouse move

I would like to draw a polygon on client mouse move.
I listen to tow event.
Mouse click(down), mouse move and maybe 'mouse up' as well.
So I want it to be like this:
First mouse click I get the first point, then when I move the mouse (awhile its still clicked) I would like to see a line with tow point, the first that clicked and the second point wich is where the mouse right now..
So when I move the mouse its like I'm drawing a line.
And when I have release the buttton (mouse up) I actually have a real line with tow points.
From there again, on mouse click/move I would have the third points of the polyline and it would move until the third click/mouse up of the mouse..

So I was able to do it with no problem with 'polyline' but with polygon I have a problem.
I was able to get something right but before I get into detail can you tell me if its even possible to do it with polyline?


Did you check DrawHelper plugin? You can find it in Plugins section.