Let's analyze the script: Line 1: create the movie clip instanced as "terrain" Line 2: set the style of the line I am going to draw Line 3: initialize a flag saying that I am not drawing Line 4: Actions to perform when the mouse is "down" (when I click the mouse) Lines 5-8: If i am not drawing, move the "pen" at current mouse location and set the drawing variable at true, to tell the script that now I am drawing Lines 9-13: If I am drawing, every time I enter the frame a line is traced from the last line drawn to the actual mouse location Lines 15-19: If the mouse is "up" (I am not clicking the mouse), the imdrawing variable is set back to false value each time I enter the frame. The onEnterFrame here may seem useles but without it, the script won't work and if you start drawing, you will continue drawing even if the mouse button is not pressed.