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.
system
2
hi,
It’s working fine for me now:
_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.
system
3
Thanx for the reply,
I will look into it as soon as i get on my comp.