HOME | DD

Published: 2008-02-04 21:00:00 +0000 UTC; Views: 3901; Favourites: 26; Downloads: 71
Redirect to original
Description
Draw with the mouse.To clear, press Space.
I made something like this before, but this time I tried to make the code as short as possible. This was the shortest I could get it with a clear function:
/* Sketch Pad v1.0 */
_quality = "LOW";
paintbrush = _root.createEmptyMovieClip("pencil", 1, {_x:0, _y:0});
drawing = _root.createEmptyMovieClip("paper", 2, {_x:0, _y:0});
drawing.lineStyle(1,0x000000,100);
drawing.moveTo(_xmouse,_ymouse);
onMouseDown = function () {
down = true;
};
onMouseUp = function () {
down = false;
};
onEnterFrame = function () {
drawing.lineStyle(1,0x000000,100);
paintbrush._x = _xmouse;
paintbrush._y = _ymouse;
if (down) {
drawing.lineTo(paintbrush._x,paintbrush._y);
} else {
drawing.moveTo(paintbrush._x,paintbrush._y);
}
if (Key.isDown(Key.SPACE)) {
drawing.clear();
}
};
Enjoy.
Related content
Comments: 28
JohnJensen In reply to mooninvanders [2011-07-24 22:42:41 +0000 UTC]
Thanks!!!
You should check out my iPhone game by clicking here (and tell your friends) !
π: 0 β©: 0
N-Szewski [2010-02-27 23:21:06 +0000 UTC]
wow, cool. what can you do with this with the code?
π: 0 β©: 0
JohnJensen In reply to The-Blazing-Cat [2008-03-27 17:00:29 +0000 UTC]
Thanks 8D
It's so Paintchat ish :0
π: 0 β©: 1
The-Blazing-Cat In reply to JohnJensen [2008-03-27 19:10:38 +0000 UTC]
Yer very welcome 8D
Ohmaigawd, I DREW YEW! :0
π: 0 β©: 0
fireheart12345 [2008-02-19 20:31:43 +0000 UTC]
for sum reason all of ur stuff keeps me occupied
π: 0 β©: 1
JohnJensen In reply to fireheart12345 [2008-02-20 14:27:31 +0000 UTC]
Thats really good to know.
Thanks
π: 0 β©: 0
mathwiz9 [2008-02-13 00:36:10 +0000 UTC]
can i use the code? It's just for my computer no one else is really going to see it. (unless my sister hacks into my files[she won't understand it{so she won't use it}])
π: 0 β©: 1
JohnJensen In reply to mathwiz9 [2008-02-13 09:20:02 +0000 UTC]
Sure c:
Credit me though.
π: 0 β©: 1
FlameReaper [2008-02-05 01:43:14 +0000 UTC]
nice short code, but i can save you three lines.
no need for the paintbrush, youcan just draw directly into the drawing clip by drawing to the mouse's x and y positions.
π: 0 β©: 1
awesty In reply to FlameReaper [2008-02-05 07:30:04 +0000 UTC]
He had it at the position of the mouses previous position, so he had the starting and ending points of the line.
But he could of just stored both values in an array, or even an empty object.
π: 0 β©: 1
DCLeadboot [2008-02-05 00:04:14 +0000 UTC]
Good stuff! Nice little drawing program there!
π: 0 β©: 0
khcat [2008-02-04 23:47:45 +0000 UTC]
this is similar to my drawing pad flash. here it is: [link]
π: 0 β©: 0
napzter [2008-02-04 22:00:35 +0000 UTC]
Den kunne godt bruge en FPS pΓ₯ 100 for at gΓΈre tegningerne mere "smooth".. PrΓΈv at checke min Sketch pad...
π: 0 β©: 0
Colin370850 [2008-02-04 21:59:03 +0000 UTC]
Its very pixelated, is there a way to make it vector? Other then that, very smooth.
π: 0 β©: 1
frozenpandaman In reply to Colin370850 [2008-02-13 00:16:52 +0000 UTC]
instead of _quality = "LOW";, change it to
_quality = "HIGH";
π: 0 β©: 1
Colin370850 In reply to frozenpandaman [2008-02-13 00:22:27 +0000 UTC]
Was that directed at me or him?
π: 0 β©: 1
Colin370850 In reply to frozenpandaman [2008-02-13 01:26:22 +0000 UTC]
Welllllllll.... NO. Heh, sorry.
π: 0 β©: 0