_doc = fl.getDocumentDOM(); _lib = _doc.library; getXML(); if(_lib.itemExists(libname)){ alert("That name exists. Please use another name."); } else { makeButton(); } function getXML(){ results = _doc.xmlPanel(fl.configURI + "Commands/aquabutton.xml"); buttonColor = results.color; libname = results.libname; width = Number(results.width); height = Number(results.height); if(width == 0){ width = 100; } if(height == 0){ height = 22; } } function makeButton(){ fixFill(); _lib.addNewItem("movie clip", libname); _lib.editItem(libname); drawBaseShape(); drawOutline(); drawHighlight(); _doc.exitEditMode(); _lib.addItemToDocument({x:_doc.width / 2, y:_doc.height / 2}, libname); _doc.selectNone(); } function fixFill(){ setVerticalFill(buttonColor, "#000000"); } function drawBaseShape(){ _tl = _doc.getTimeline(); _layer = _tl.layers[0]; _layer.name = "base"; drawHorizontalButton(0, 0, width, height); _doc.selectAll(); setVerticalFill(buttonColor, "#ffffff"); _layer.locked = true; } function drawOutline(){ _tl.addNewLayer("outline", "normal", true); _tl.currentLayer = 0; _layer = _tl.layers[0]; _fill = _doc.getCustomFill("toolbar"); _fill.color = "#00000022"; _fill.style = "solid"; _doc.setCustomFill(_fill); drawHorizontalButton(0, 0, width, height); _fill.color = "#ffffff"; _fill.style = "solid"; _doc.setCustomFill(_fill); drawHorizontalButton(1, 1, width - 2, height - 2); _doc.mouseClick({x:width/2, y:height/2}, false, false); _doc.clipCut(); _layer.locked = true; } function drawHighlight(){ _tl.addNewLayer("highlight", "normal", true); _tl.currentLayer = 0; _layer = _tl.layers[0]; setVerticalFill("#ffffff", "#ffffff00"); drawHorizontalButton((height - 2) / 4, 1, width - (height - 2) / 2, (height - 2) / 2); _doc.selectAll(); setVerticalFill("#ffffff", "#ffffff00"); _layer.locked = true; } function drawHorizontalButton(x, y, w, h){ _doc.addNewOval({left:x, top:y, right:h+x, bottom:h+y}, false, true); _doc.addNewRectangle({left:x+h/2, top:y, right:w+x-h/2, bottom:h+y}, 0, false, true); _doc.addNewOval({left:w+x-h, top:y, right:w+x, bottom:h+y}, false, true); } function resetFill(){ _fill = new Object(); _fill.color = "#ffffff"; _fill.style = "solid"; _fill.colorArray = ["#ffffff", "#ffffff00"]; _fill.matrix = makeFillMatrix(0, 0, 100, 22, Math.PI / 2); _fill.posArray = [0, 255]; _doc.setCustomFill(_fill); } function setVerticalFill(col1, col2){ resetFill(); _fill = _doc.getCustomFill("toolbar"); _fill.color = "#ffffff"; _fill.colorArray = [col1, col2]; _fill.matrix = makeFillMatrix(0, 0, 100, 22, Math.PI / 2); _fill.posArray = [0, 255]; _fill.style = "linearGradient"; _doc.setCustomFill(_fill); } function makeFillMatrix(x, y, w, h, a){ var maxSize = 32768/20; var scaleX = w/maxSize; var scaleY = h/maxSize; var mat = new Object(); mat.a = Math.round(Math.cos(a) * scaleX * 1000)/1000; mat.b = Math.round(Math.sin(a) * scaleX * 1000)/1000; mat.c = -Math.round(Math.sin(a) * scaleY * 1000)/1000; mat.d = Math.round(Math.cos(a) * scaleY * 1000)/1000; mat.tx = x + w/2; mat.ty = y + h/2; return mat; }