# HELP WITH DRAWING :) clear(); problem

**URL:** <https://forum.kirupa.com/t/help-with-drawing-clear-problem/64885>\
**Category:** flash\
**Created:** [September 21, 2004, 12:02am UTC](https://forum.kirupa.com/t/help-with-drawing-clear-problem/64885 "2004-09-21T00:02:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alphaOne](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@alphaOne](https://forum.kirupa.com/u/alphaOne)\
**Post date:** [September 21, 2004, 12:02am UTC](https://forum.kirupa.com/t/help-with-drawing-clear-problem/64885/1 "2004-09-21T00:02:36Z")

</div>

hi, i am experimenting with the drawing methods. I have created this code

\_root.createEmptyMovieClip(“line”, 1);  
drawIT.onPress = function() {  
cool = function () {  
i++;  
with (line) {  
lineStyle(0, 0x000000, 50);  
moveTo(100, 100);  
if (i\<=50) {  
lineTo(100+i, 100+i);  
}  
}  
};  
setInterval(cool, 10);  
};  
clearIT.onPress = function() {  
with (line) {  
clear();  
}  
};

The good news: It actually draws a line from (100,100) to (150,150) and it clears the line when i press the clearIT button…

The bad news: After i press the clearIT button, the drawIT button doesnt draw the line anymore…

So, my question is : How do i bring my line back?..

Thanx in advance,  
alphaOne.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 21, 2004, 3:43am UTC](https://forum.kirupa.com/t/help-with-drawing-clear-problem/64885/2 "2004-09-21T03:43:23Z")

</div>

hi,

It’s working fine for me now:

```auto

_root.createEmptyMovieClip("line", 1);
drawIT.onPress = function()
{
	i = 0; // initialize the variable
	cool = function ()
	{
		i++;
		with (line)
		{
			lineStyle(0, 0x000000, 50);
			moveTo(100, 100);
			if (i <= 50)
			{
				lineTo(100 + i, 100 + i);
				
			}
			else
			{
				// stop using setInterval()
				clearInterval(myInterval);
			}
		}
	};
	myInterval = setInterval(cool, 10); // assign to a variable
};
clearIT.onPress = function()
{
	line.clear();
	// stop using setInterval()
	clearInterval(myInterval);
};

```

I guess you’re on MX.  
In MX 2004 (FP7) you need to initialize the variable.

You should stop calling the function when you don’t need it anymore with _clearInterval()_, so.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 21, 2004, 2:49pm UTC](https://forum.kirupa.com/t/help-with-drawing-clear-problem/64885/3 "2004-09-21T14:49:40Z")

</div>

Thanx for the reply,  
I will look into it as soon as i get on my comp.
