Hi guys, I'm just learning actionscripting, and did a tutorial on how to make a drawing board. I was wondering if anyone has the time to break down the code for me so I could understand it a bit better. I've attached the swf. and the code below.

Thanks
Z?

var x = y=lastx=lasty=0;
var down = false;
var k = 0;
var smooth = 4;
var chkSmooth = 2;
var switchSmooth = false;
var col = 0x00ff00;
var thk = 5;
var alpha = 100;
var line = createEmptyMovieClip("line", 0);
line.lineStyle(thk, col, alpha);


Mouse.hide();
pencil.swapDepths(99);
hand.swapDepths(100)
this.onMouseDown = function() {
down = true;
x = lastx=_xmouse;
y = lasty=_ymouse;
line.moveTo(lastx, lasty);
};
this.onMouseUp = function() {
down = false;
};

this.onMouseMove = function() {
line.lineStyle(thk, col, alpha);
if (bg.hitTest(_xmouse, _ymouse, true)) {
hand._visible = false;
pencil._visible = true;
pencil._x = _xmouse;
pencil._y = _ymouse;
if (down) {
k++;
if (k == 36) {
k = 0;
}
if (k%smooth == chkSmooth) {

line.curveTo(x, y, lastx=(x+_xmouse)/2, lasty=(y+_ymouse)/2);
x = _xmouse;
y = _ymouse;
}
}
} else {
pencil._visible = false;
hand._visible = true;
hand._x = _xmouse;
hand._y = _ymouse;
}
};
var kl:Object = new Object();
kl.onKeyDown = function() {
switchSmooth = !switchSmooth;
if (switchSmooth) {
smooth = 9;
chkSmooth = 3;
} else {
smooth = 4;
}
chkSmooth = 2;
};
Key.addListener(kl);
function checkDist(x, x2, y, y2):Number {
return Math.round(Math.sqrt(Math.pow(x-x2)+Math.pow(y-y2)))
}
function moveMark(target:MovieClip):Void {
mark.onEnterFrame = function() {
this._x += (target._x-this._x)/6;
this._y += (target._y-this._y)/6;
};
}

//paint colors and name in dynamic txt box

blue.onPress = function() {
col = 0x0000ff;
colText.text = "Your colour is: "+this._name;
moveMark(this);
};
green.onPress = function() {
col = 0x009900;
colText.text = "Your colour is: "+this._name;
moveMark(this);
};
pink.onPress = function() {
col = 0xff00ff;
colText.text = "Your colour is: "+this._name;
moveMark(this);
};
purple.onPress = function() {
col = 0x6600ff;
colText.text = "Your colour is: "+this._name;
moveMark(this);
};
yellow.onPress = function() {
col = 0xffff00;
colText.text = "Your colour is: "+this._name;
moveMark(this);
};
red.onPress = function() {
col = 0xcc0000;
colText.text = "Your colour is: "+this._name;
moveMark(this);
};
orange.onPress = function() {
col = 0xff6600;
colText.text = "Your colour is: "+this._name;
moveMark(this);
};
cyan.onPress = function() {
col = 0x00FFFF;
colText.text = "Your colour is: "+this._name;
moveMark(this);
};

// clears the page when clear button is pressed

clear.onPress = function(){
line.clear()
}