Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Background

Status
Not open for further replies.

diminionone

Technical User
Dec 5, 2006
1
US
Hey, I'm following a tutorial on making a drawing pad in flash, using this code.
Code:
lineThickness = 0;
selectedColor = "0x000000";
_root.onMouseDown = startDrawing;
_root.onMouseUp = stopDrawing;
function startDrawing() {
   if (_xmouse<455) {
      _root.lineStyle(lineThickness, selectedColor);
      _root.moveTo(_root._xmouse, _root._ymouse);
      _root.onMouseMove = drawLine;
   }
}
function drawLine() {
   _root.lineTo(this._xmouse, this._ymouse);
}
function stopDrawing() {
   delete this.onMouseMove;
}
I've got everything working, but I'd like to add a background on which users can draw on. So basically, how would I go about telling flash to display on a layer, rather on the root space? Thanks
 
What you need to do is instead of drawing direct on _root, create a MovieClip and draw in it.
Code:
var padMC = this.createEmptyMovieClip("mcPad", 1);
lineThickness = 0;
selectedColor = "0x000000";
this.onMouseDown = startDrawing;
this.onMouseUp = stopDrawing;
function startDrawing() {
	if (_xmouse<455) {
		padMC.lineStyle(lineThickness, selectedColor);
		padMC.moveTo(_xmouse, _ymouse);
		this.onMouseMove = drawLine;
	}
}
function drawLine() {
	padMC.lineTo(_xmouse, _ymouse);
}
function stopDrawing() {
	delete this.onMouseMove;
}

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top