Hey
I would be so happy if anyone could help me out on this one. I have made a sketchpad and want to be able to contain the drawing within some boundaries. So far I’ve managed to set boundaries so that I can’t start to draw outside some x and y values but if I start drawing inside those I can continue to draw all over the stage. So I need something to make it stop drawing when the mouse is going out of the boundary values.
Well here is my code so far:
lineThickness = 3;
selectedColor = “0xffffff”;
this.onMouseDown = startDrawing;
this.onMouseUp = stopDrawing;
function startDrawing() {
if (_xmouse>1 && _xmouse<935 && _ymouse>0 && _ymouse<511) {
this.lineStyle(lineThickness, selectedColor);
this.moveTo(this._xmouse, this._ymouse);
this.onMouseMove = drawLine;
}
}
function drawLine() {
this.lineTo(this._xmouse, this._ymouse);
}
function stopDrawing() {
delete this.onMouseMove;
}
line0.onPress = function() {
lineThickness = 0;
};
line3.onPress = function() {
lineThickness = 3;
};
line6.onPress = function() {
lineThickness = 6;
};
colorRed.onPress = function() {
selectedColor = “0xFF0000”;
};
colorGreen.onPress = function() {
selectedColor = “0x00FF00”;
};