Problem with drawing board program

i’m creating a drawing program. so far it allows the user to draw a rectangular prism on the screen but when they draw another one, the previous prism is erased. how can overcome this problem? here is the AS…

[AS]_root.createEmptyMovieClip(“cube”, 1);
_root.onMouseDown = function() {
x1 = _xmouse;
y1 = _ymouse;
this.onMouseMove = function() {
//data on different points
//lineTo stuff
};
};
_root.onMouseUp = function() {
this.onMouseMove = null;
};[/AS]

just guessing:


this.onLoad = function(){
	i = 0;
}
_root.onMouseDown = function() {
  _root.createEmptyMovieClip("cube"+i, i);
  x1 = _root._xmouse;
  y1 = _root._ymouse;
  this.onMouseMove = function() {
    //data on different points
    //lineTo stuff

    };
};
_root.onMouseUp = function() {
  i++;
  this.onMouseMove = null;
};

untested, hope it works.

thanks, your script didn’t work but it gave me an idea and i fixed the problem… thanks again :slight_smile:

lol. Glad I could be of “help” (-:

okay, new problem. i have a function (drawCube) and i only want it to run when the key CONTROL is down what I have (which doesn’t work) is :

[AS]controller = function () {
if (Key.isDown(Key.CONTROL)) {
drawCube ()
}
}[/AS]

the function happens even when i’m not pressing control. any help?

i really dont have a clue, but you might be able to do an if/else situation

really no idea:P

hawk

what would i put in the else statement?

[AS]
controller = function () {
if (Key.isDown(Key.CONTROL)) {
drawCube ()
}
else {
//do the other thing you want it to do - not drawCube
}
}
[/AS]

like i said, i really dont know :smiley:

nope, doesn’t work… now nothing happens :frowning:

why is the if-statement placed inside the ‘controller’ function?.. try something like this

onMouseDown = function() {
	if(Key.isDown(Key.CONTROL)) {
		trace("drawCube()")
		drawCube()
	}
}

one more thing, how do i get the function to stop running when i stop holding control? btw, thanks for the help :slight_smile:

hm… im not sure, but i think the function is automoatically killed once the mouse is released…

for some reason its not…

well i dont know