Skip to main content
Known Participant
May 1, 2008
Question

Containing Mouse Drawing Movement

  • May 1, 2008
  • 2 replies
  • 440 views
Hello,

I'm creating a 'white board' file.. where the mouse cursor changes to a pencil, and the user can use it to write on the 'white board'. I've got it working in principal.. however I'd like to contain the area of the 'white board', as currently the user can scribble all over the page. I'm currently useing this code to make things work:

startDrag("mousePen",true);
mousePen.swapDepths(2);
Mouse.hide();
this.createEmptyMovieClip("line",1);

this.onMouseDown = function() {
line.moveTo(_xmouse,_ymouse);
line.lineStyle(2,0x333333,100);

this.onMouseMove = function() {
line.lineTo(_xmouse,_ymouse);
updateAfterEvent();
}
}
this.onMouseUp = function() {
this.onMouseMove = null;
}


The area I want to constrain to is 130 x 190. I've played with hitTest but couldn't make it work, and also tried to constrain the mouse Drag with:

startDrag(this, true, 1, 1, 1, 1); - NB co-ords not correct.

This work to constrain the mouse drag, but the pencil line drawing continues without the pencil cursor attached.

I know I'm close but just cant work it out.. can anyone offer any advice?

Many thanks in advance.
This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
May 1, 2008
1. use

mousePen._visible = true;

next to Mouse.hide();

and

mousePen._visible=false;

next to Mouse.show() and

2. change:

LRdrawRect[0] to

LRdrawRectA[0]
kglad
Community Expert
Community Expert
May 1, 2008
in your mousemove handler use an if-statement to check the _xmouse,_ymouse properties and if they are in your contrained area, startDrag(), hide the mouse and execute your line-draw code.
JOliver77Author
Known Participant
May 1, 2008
Hi, thanks for the reply. I'm pretty new to actionscript.. could you be a bit more specific? I'm not too good a coding on my own at the min... but i'm trying to learn
kglad
Community Expert
Community Expert
May 1, 2008
try: