zylum
April 11, 2003, 6:20pm
1
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]
system
April 11, 2003, 7:06pm
2
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.
system
April 11, 2003, 7:42pm
3
thanks, your script didn’t work but it gave me an idea and i fixed the problem… thanks again
system
April 11, 2003, 7:47pm
4
lol. Glad I could be of “help” (-:
system
April 12, 2003, 9:39pm
5
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?
system
April 12, 2003, 9:43pm
6
i really dont have a clue, but you might be able to do an if/else situation
really no idea:P
hawk
system
April 12, 2003, 9:44pm
7
what would i put in the else statement?
system
April 12, 2003, 10:10pm
8
[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
system
April 12, 2003, 10:19pm
9
nope, doesn’t work… now nothing happens
system
April 12, 2003, 10:28pm
10
why is the if-statement placed inside the ‘controller’ function?.. try something like this
onMouseDown = function() {
if(Key.isDown(Key.CONTROL)) {
trace("drawCube()")
drawCube()
}
}
system
April 12, 2003, 10:39pm
11
one more thing, how do i get the function to stop running when i stop holding control? btw, thanks for the help
system
April 13, 2003, 12:39am
12
hm… im not sure, but i think the function is automoatically killed once the mouse is released…