// __ _ _ // _\ |_ _____ ____| |__ ____ _____ ____ __| | // \__ __| _ | _ | _ | _ | _ | __| _ | // |__\ |___,_|__ |____|____|___,_|_| |____) // /___| // // 2002 BY AEMKEI // see www.mizubitchy.com for more stuff // global variables var version = "v1.00"; var thickness = 7; // pen is 7 units thick var paintInterval = 50; // update every 50 ms var startup = true; hotkey = new Object(); hotkey.deleteLast = "D"; hotkey.showXML = "X"; hotkey.showMEL = "M"; hotkey.hideOutput = "H"; hotkey.deleteAll = "Q"; hotkey.showInfo = "I"; // perform actions depending on last pressed key hotkey.onKeyDown = function() { lastKey = new String(); lastKey = String.fromCharCode(Key.getAscii()).toUpperCase(); switch (lastKey) { case this.deleteLast : shape.deleteLast(); break; case this.deleteAll : shape.deleteAll(); break; case this.showXML : output.show("XML"); break; case this.showMEL : output.show("MEL"); break; case this.showInfo : output.show("INFO"); break; case this.hideOutput : output.hide(); break; } } this.onLoad = function () { Stage.scaleMode ="noScale"; Key.addListener(hotkey); setInterval( this, "myMouseMove", paintInterval ); } this.onMouseDown = function () { drag = true; coord[1].x = _xmouse; coord[1].y = _ymouse; if (firstVisible) { firstVisible = false; shape.deleteAll(); } } // stop paint action this.onMouseUp = function() { drag = false; if (pointNum > 1) { shape.paintSmooth(); shape.keep(); } else pointNum = 0; } this.myMouseMove = function () { if ((startup == false) && (output._visible == false)) { if (drag){ oldX = coord[pointNum-1].x; oldY = coord[pointNum-1].y; newX = _xmouse; newY = _ymouse; coord[pointNum].x = newX; coord[pointNum].y = newY; distX = Math.abs(oldX - newX); distY = Math.abs(oldY - newY); if ((distX > 2) || (distY > 2)){ pointNum ++; shape.paintStraight(); } } } if ((ASnative(800,2)(1)) == false) { // calls mouseUp even if its out of focus this.onMouseUp(); } } this.onEnterFrame = function () { if (startup && XMLdata.loaded) shape.paintRecorded(); } // __ // ____| |__ _____ ____ ____ ___ // {_ (| | _ | _ | - _) ___\ \ // /_____)__|__|___,_| __|____/ |_______\ // |_| var depth = 1; var pointNum = 1; var shapeNum = 0; createEmptyMovieClip ("shape", 0); // PAINTSMOOTH renders the painting shape.paintSmooth = function () { this.clear(); this.lineStyle (3, 0xFFFFFF, 100); this.moveTo( coord[0].x, coord[0].y ); for (i=1; i < pointNum-1; i++){ x = coord[i].x; y = coord[i].y; x2 = (coord[i].x + coord[i+1].x) / 2; y2 = (coord[i].y + coord[i+1].y) / 2; this.curveTo(x, y, x2, y2); } x = coord[pointNum-1].x; y = coord[pointNum-1].y; this.lineTo(x,y); } // PAINTSTRAIGHT is used for fast interactive painting shape.paintStraight = function () { if (pointNum == 1) { this.clear(); this.lineStyle(1, 0xFFFFFF, 100); this.moveTo(_xmouse, _ymouse); this._visible = true; } x = _xmouse; y = _ymouse; this.lineTo(x, y); } // KEEP copies the shape and make it looks like taged shape.keep = function () { shapeData.addPoints(); shapeNum ++; for (i=0; i < thickness; i++) { depth ++; this.duplicateMovieClip("shape" + depth, depth); eval("shape" + depth)._y += i - thickness / 2; eval("shape" + depth)._x -= i/4; } pointNum = 0; this._visible = false; } // DELETELAST removes the last shape and it's data shape.deleteLast = function () { if (shapeNum > 0) { for (i=0; i < thickness; i++) { lastShape = eval("shape" + depth); lastShape.removeMovieClip(); depth --; } shapeData.pop(); shapeNum --; } } shape.deleteAll = function () { while (shapeNum > 0) shape.deleteLast(); } // PAINTRECORDED performs the last tag frame by frame shape.paintRecorded = function () { tempArray = shapeData[shapeNum].split(","); pointNum = tempArray.length/2; for(j=0; j < pointNum; j++){ coord[j].x = Number(tempArray[j*2]); coord[j].y = Number(tempArray[j*2+1]); } shape.paintSmooth(); shape.keep(); if (shapeNum >= shapeData.length) { startup = false; firstVisible = true; } } // _ __ // __| |_____ _\ |_ _____ ___ // | _ | _ |__ __| _ | ___\ \ // |____|___,_| |__\ |___,_| |_______\ coord = new Array(); for (i=0; i<300; i++) coord[i] = new Object(); shapeData = new Array(); shapeData.addPoints = function () { var arr = new Array(); for (i=0; i < pointNum; i++) { arr[i*2] = Math.round(coord[i].x); arr[i*2+1] = Math.round(coord[i].y); } this[shapeNum] = arr; } shapeData.toXML = function () { var str = new String(); str += "\n"; str += "\n"; for (i=0; i\n"; str += ""; return str; } shapeData.toMEL = function () { var str = new String(); str = "// Tagboard " + version + " by aemkei@mizubitchy.com \n"; str += "// MEL Script Output (Beta!!!)\n\n"; str += "file -f -new; \n" str += "\ncurve -d 3 -p 1 3 0 -p 0.5 1.5 0 -p 0 0 0 -p -0.5 -1.5 0 -p -1 -3 0; \n" str += "select -r curve1; \n" str += "rename \"curve1\" \"stroke\"; \n\n"; for (i=0; i