homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

Creating flash 'whiteboard'
i have a script but need to modify it

 12:14 pm on Jun 3, 2004 (gmt 0)

I want to create a flash movie that has a board you can draw on. I found this script on the net somewhere which creates a simple drawing pad which is great.

However I need to make this so that the drawing board is only part of the movie, rather than the whole movie, as it is presently. ie I want the drawing pad to sit inside some other graphics.

Here is the code:

function init() {

function initDrawing() {
createEmptyMovieClip("draw_mc", 10);
draw_mc.lineStyle(2, 0x000000);
createEmptyMovieClip("temp_mc", 20);

function initMouse() {
mouseMoveListener = new Object();
mouseMoveListener.onMouseMove = function() {
mouseClickListener = new Object();
mouseClickListener.onMouseDown = function() {
mouseClickListener.onMouseUp = function() {

function mouseDownEvent() {
draw_mc.moveTo(_xmouse, _ymouse);

function mouseUpEvent() {

function mouseMoveEvent() {
// Remove any previous drawing
// Draw dot at End Point
temp_mc.lineStyle(6, 0x00ff00);
temp_mc.moveTo(_xmouse, _ymouse);
temp_mc.lineTo(_xmouse + 0.5, _ymouse);
// Draw line segment
draw_mc.lineTo(_xmouse, _ymouse);

// this actionscript goes in frame 1

I am able to use flash on a quite basic level and am happy to play with the actionscript, even if I'm not always sure what I'm doing!

Any help would be much appreciated.



 12:43 pm on Jun 3, 2004 (gmt 0)

try publishing that from flash to create a self contained .swf containing the whiteboard, then in the parent movie with the other graphics use loadMovie [macromedia.com] to load the whiteboard in.


<added> alternatively, you could create a new moiveclip (insert > symbol) and add that script to the first frame of the new movieclips timeline.

you can then drag that new movieclip from the library onto the stage with the rest of your graphics etc


 3:01 pm on Jun 3, 2004 (gmt 0)

Cheers for the reply ben.

When I create the movieclip and drop this in, it works, but I don't know how to get the movieclip (drawing pad) to be the exact size I want. At the moment the user can draw all over the surroundings.

it is possible that it's past dumb o'clock for me


 3:14 pm on Jun 3, 2004 (gmt 0)

hmm . didnt think of that.

you could possibly add an if statement to check the mouses position before drawing, something alongm the lines of:

function mouseDownEvent() {
if (_xmouse>=100&&_xmouse=<400&&_ymouse>=100&&_ymouse=<400)
draw_mc.moveTo(_xmouse, _ymouse);

so basically you can only draw if the mouse is between 100 and 400 px along both the x axis and y axis - experiment with co-ordinates to suit.

note: totally untested code. sounds ok in theory but...


 3:34 pm on Jun 3, 2004 (gmt 0)

Cheers again ben. You look like a bit of a flash pro to me. I shall come to you with all my flash problems ;)

It just occured to me to put the 'surroundings' in the layer above the movieclip and voila, it works. Told you it was past dumb o'clock :)


 3:37 pm on Jun 3, 2004 (gmt 0)

yep thats probably a much better idea .

flash problems

he he - i tend to goto to winstun when hes about :)

good luck


 3:44 pm on Jun 3, 2004 (gmt 0)

Also if you're putting the drawing pad mc into a container ( blank mc to 'hold' the pad ) then you could put:
function mouseDownEvent() {
var clip = this._parent;
if (_xmouse>=clip._x&&_xmouse=<(clip._x+clip._width)&&_ymouse>=clip._y&&_ymouse=<(clip._y+clip._height)){
draw_mc.moveTo(_xmouse, _ymouse);

This way it's more dynamic and re-usable so you can use it in other applications and with the option of resizing it.
Long story short is so you don't have go in and edit the function every time you need a different size.


 3:47 pm on Jun 3, 2004 (gmt 0)

Thanks for the props, Ben, but just doing my part to help out. :)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved