codice:
function Drawing(__path, __color) {
// andr3a, scritta al volo il 28/01/2006
// compatibile Flash 6, 7, 8 .. forse pure FlashLite 2.0
function __init(__path, __s, __color) {
var __listener = __initListener(__path, __s, __color);
Mouse.addListener(__listener);
__initMenu(__path, __listener);
};
function __initListener(__path, __s, __color) {
var __listener = new Object();
__listener.path = __path[__s];
__listener.onMouseDown = function() {
this.__draw = true;
this.path.moveTo(__path._xmouse, __path._ymouse);
};
__listener.onMouseMove = function() {
if(this.__draw) {
with(this.path) {
lineStyle(1, __color);
lineTo(__path._xmouse, __path._ymouse);
}
}
};
__listener.onMouseUp = function() {
this.__draw = false;
};
__listener.clearDrawed = function() {
__path[__s].clear();
};
return __listener;
};
function __initMenu(__path, __listener) {
if(ContextMenu) {
var __cmenu = new ContextMenu();
__cmenu.customItems.push(new ContextMenuItem("Clear", __listener.clearDrawed));
__path.menu = __cmenu;
};
};
function __depth(__path) {
var __depth = 1000;
if(__path.getNextHighestDepth)
__depth = __path.getNextHighestDepth();
return __depth;
};
var __s = '__drawing__' + Math.random() * 123456789 + '__';
__path.createEmptyMovieClip(__s, __depth(__path));
__init(__path, __s, __color);
}
Drawing(this, 0x00000);