Using Drawing API

Hi,

Does anyone know how to replicate the “add anchor point” tool using AS2? I have managed to use the API to draw a square with four anchor points, but am not sure how to add extra anchor points. What I want is that these extra anchor points are added when then user clicks on a line.

Here is my example:

www.davidjamesroberts.co.uk/work/drawingAPI.html

Thanks in advance