Hmm. The for loop serves no purpose, you're just creating 10 objects at a time that are the same. You probably should set the width to the distance from the mouse. Also changing the image x offset could be useful, probably it would relate to the total distance so far.
Anyways here's a different way to do it. I'm sure there are many other ideas.
https://www.dropbox.com/s/wh1hf0ji0sueive/draw_dashed.capx?dl=1
As always, U R the best
Many thanks