This is a quick Flash App that I did yesterday for my actionscript class. It’s fairly basic and looks cool! This is all done with 3 layers and 1 keyframe in each layer. I did do the pencil with Maya but you could use anything. It’s just a .png file for the transparency. I turned it into a Movie Clip named pencil_mc. Put it on the stage and then just added the script. See the rest of this post for the code.
Just insert this code into your first frame keyframe, create a new empty movie clip named empty_mc, and create a pencil or something called pencil_mc, and done!
// the pencil starts to drag. the regular mouse cursor is also hidden for better effect!
startDrag(pencil_mc, true);
Mouse.hide();
// create a variable and assign it a boolean
var drawing:Boolean = false;
//created key listener to listen for SPACE press then clear canvas
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(32)) {
empty_mc.clear();
}
};
//created mouse listener to listen for mouse down then draw
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
empty_mc.lineStyle(3, 0x999999, 50); //line(width, color, opacity)
empty_mc.moveTo(_xmouse, _ymouse);
drawing = true;
};
mouseListener.onMouseMove = function() {
if (drawing) {
empty_mc.lineTo(_xmouse, _ymouse);
updateAfterEvent();
}
};
mouseListener.onMouseUp = function() {
drawing = false;
};
Mouse.addListener(mouseListener);
Key.addListener(keyListener);
Download the zip file here









No comments yet.
Leave a comment