1 Attachment(s)
I keep posting this way too much, however I need help breaking down this code...
I just figured how to make a drawing board in flash, but need some help with a few things:
1. How do i keep the drawing inside of the canvas?
2. How do i draw shapes?
3. How can i make different sized brushes?
I have attached the file, so if you can help, take a look at it and see what i'm doing wrong.
Need help with drawing board
Hi guys,
I'm trying to make a sketch pad, and it works. The only problem I'm having is that when I go to the help section, which is in the second frame, and go back to the first frame, it brings the curser back with it...so there's two cursors. Anyone know why and how I can fix that?
Thanx,
z?
Need help breaking down this code...
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. I just just copy and paste the code and insert ur explanation above it...even if you don't know all of it...anything will help
Thanks
:)
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()
}