PDA

View Full Version : problem with drawing board program...



zylum
April 11th, 2003, 02:20 PM
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...

_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;
};

Flashmatazz
April 11th, 2003, 03:06 PM
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.

zylum
April 11th, 2003, 03:42 PM
thanks, your script didn't work but it gave me an idea and i fixed the problem... thanks again :)

Flashmatazz
April 11th, 2003, 03:47 PM
lol. Glad I could be of "help" (-:

zylum
April 12th, 2003, 05:39 PM
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 :

controller = function () {
if (Key.isDown(Key.CONTROL)) {
drawCube ()
}
}

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

Hawk
April 12th, 2003, 05:43 PM
i really dont have a clue, but you might be able to do an if/else situation

really no idea:P

hawk

zylum
April 12th, 2003, 05:44 PM
what would i put in the else statement?

Hawk
April 12th, 2003, 06:10 PM
controller = function () {
if (Key.isDown(Key.CONTROL)) {
drawCube ()
}
else {
//do the other thing you want it to do - not drawCube
}
}


like i said, i really dont know :D

zylum
April 12th, 2003, 06:19 PM
nope, doesn't work.. now nothing happens :(

ahmed
April 12th, 2003, 06:28 PM
why is the if-statement placed inside the 'controller' function?.. try something like this
onMouseDown = function() {
if(Key.isDown(Key.CONTROL)) {
trace("drawCube()")
drawCube()
}
}

zylum
April 12th, 2003, 06:39 PM
one more thing, how do i get the function to stop running when i stop holding control? btw, thanks for the help :)

!*@&
April 12th, 2003, 08:39 PM
hm.. im not sure, but i think the function is automoatically killed once the mouse is released...

zylum
April 12th, 2003, 09:10 PM
for some reason its not...

!*@&
April 13th, 2003, 03:12 AM
well i dont know