Cloned from http://flashcanvas.net/examples/grenlibre.fr/demo/same/