📄 aqualook.as
字号:
movie.endFill(); colors.splice(0); alphas.splice(0); ratios.splice(0); colors.push(0xffffff, 0xffffff, 0xffffff); //alphas.push(65, 40, 35); alphas.push(50, 25, 20); ratios.push(10, 50, 100); var offX:Number = 1; var offY:Number = 1; var dY:Number = 1; matrix = {matrixType:"box", x:offX, y:offY, w:w1, h:r1 * 2, r:Math.PI / 2}; movie.beginGradientFill("linear", colors, alphas, ratios, matrix); this.drawRoundRect(movie, x + 1 + r1 / 4, y + dY, w - 1 - r1 / 4, r1 - 0.5, r); movie.endFill(); colors.splice(0); alphas.splice(0); ratios.splice(0); colors.push(0xffffff, 0xffffff); alphas.push(0, 50); //85 ratios.push(90, 235); var offX:Number = 1; var offY:Number = y + h - r1 * 2 - 1; matrix = {matrixType:"box", x:offX, y:offY, w:w1, h:r1 * 2, r:Math.PI / 2}; movie.beginGradientFill("linear", colors, alphas, ratios, matrix); this.drawRoundRect(movie, x + 1, y + h - r1 * 2 - 1, w - 1, y + h - 1, r); movie.endFill(); } this.drawRoundRect(movie, x + 0.5, y + 0.5, w - 0.5, h - 0.5, r - 0.5, globalStyleFormat[data.pLink._darkshadow], 100, 1); movie.lineStyle(undefined); if(data.mode == "press") this.fillRoundRect(movie, x, y, w, h, r, 0, 20); if(movie.mask == undefined || movie._width != movie.mask._width || movie._height != movie.mask._height) { var mask:MovieClip = movie.createEmptyMovieClip('mask', 200); this.fillRoundRect(mask, x, y, w, h, r, 0, 0); mask._visible = false; movie.setMask(mask); }} _global.AquaLook.prototype.fillRoundRect = function(movie:MovieClip, x:Number, y:Number, w:Number, h:Number, r:Number, bgCol:Number, bgAlpha:Number, lineCol:Number, lineAlpha:Number):Void{ if(!bgAlpha) bgAlpha = 100; movie.beginFill(bgCol, bgAlpha) this.drawRoundRect(movie, x, y, w, h, r, lineCol, lineAlpha); movie.endFill();} _global.AquaLook.prototype.drawRoundRect = function(movie:MovieClip, nX1:Number, nY1:Number, nX2:Number, nY2:Number, cornerRadius:Number, color:Number, alpha:Number, nSize:Number):Void{ if(nSize == undefined || nSize == null) nSize = 1; if(alpha == undefined) alpha = 100; if(color == null || color == undefined) movie.lineStyle(undefined); else movie.lineStyle(nSize, color, alpha); var x:Number = Math.min(nX1, nX2); var y:Number = Math.min(nY1, nY2); var w:Number = Math.abs(nX2 - nX1); var h:Number = Math.abs(nY2 - nY1); // ============== // mc.drawRect() - by Ric Ewing (ric@formequalsfunction.com) - version 1.1 - 4.7.2002 // // x, y = top left corner of rect // w = width of rect // h = height of rect // cornerRadius = [optional] radius of rounding for corners (defaults to 0) // ============== if (arguments.length < 4) return; // if the user has defined cornerRadius our task is a bit more complex. :) if (cornerRadius > 0) { // init vars var theta, angle, cx, cy, px, py; // make sure that w + h are larger than 2*cornerRadius var cr:Number = Math.min(w, h) / 2; if (cornerRadius > cr) cornerRadius = cr; // theta = 45 degrees in radians theta = Math.PI / 4; // draw top line movie.moveTo(x + cornerRadius, y); movie.lineTo(x + w - cornerRadius, y); //angle is currently 90 degrees angle = -Math.PI / 2; // draw tr corner in two parts cx = x + w - cornerRadius + (Math.cos(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); cy = y + cornerRadius + (Math.sin(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); px = x + w - cornerRadius + (Math.cos(angle + theta) * cornerRadius); py = y + cornerRadius + (Math.sin(angle + theta) * cornerRadius); movie.curveTo(cx, cy, px, py); angle += theta; cx = x + w - cornerRadius + (Math.cos(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); cy = y + cornerRadius + (Math.sin(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); px = x + w - cornerRadius + (Math.cos(angle + theta) * cornerRadius); py = y + cornerRadius + (Math.sin(angle + theta) * cornerRadius); movie.curveTo(cx, cy, px, py); // draw right line movie.lineTo(x + w, y + h - cornerRadius); // draw br corner angle += theta; cx = x + w - cornerRadius + (Math.cos(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); cy = y + h - cornerRadius + (Math.sin(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); px = x + w - cornerRadius + (Math.cos(angle + theta) * cornerRadius); py = y + h - cornerRadius + (Math.sin(angle + theta) * cornerRadius); movie.curveTo(cx, cy, px, py); angle += theta; cx = x + w - cornerRadius + (Math.cos(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); cy = y + h - cornerRadius + (Math.sin(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); px = x + w - cornerRadius + (Math.cos(angle + theta) * cornerRadius); py = y + h - cornerRadius + (Math.sin(angle + theta) * cornerRadius); movie.curveTo(cx, cy, px, py); // draw bottom line movie.lineTo(x+cornerRadius, y+h); // draw bl corner angle += theta; cx = x + cornerRadius + (Math.cos(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); cy = y + h - cornerRadius + (Math.sin(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); px = x + cornerRadius + (Math.cos(angle + theta) * cornerRadius); py = y + h - cornerRadius + (Math.sin(angle + theta) * cornerRadius); movie.curveTo(cx, cy, px, py); angle += theta; cx = x + cornerRadius + (Math.cos(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); cy = y + h - cornerRadius + (Math.sin(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); px = x + cornerRadius + (Math.cos(angle + theta) * cornerRadius); py = y + h - cornerRadius + (Math.sin(angle + theta) * cornerRadius); movie.curveTo(cx, cy, px, py); // draw left line movie.lineTo(x, y + cornerRadius); // draw tl corner angle += theta; cx = x + cornerRadius + (Math.cos(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); cy = y + cornerRadius + (Math.sin(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); px = x + cornerRadius + (Math.cos(angle+ theta) * cornerRadius); py = y + cornerRadius + (Math.sin(angle + theta) * cornerRadius); movie.curveTo(cx, cy, px, py); angle += theta; cx = x + cornerRadius + (Math.cos(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); cy = y + cornerRadius + (Math.sin(angle + (theta / 2)) * cornerRadius / Math.cos(theta / 2)); px = x + cornerRadius + (Math.cos(angle + theta) * cornerRadius); py = y + cornerRadius + (Math.sin(angle + theta) * cornerRadius); movie.curveTo(cx, cy, px, py); } else { // cornerRadius was not defined or = 0. This makes it easy. movie.moveTo(x, y); movie.lineTo(x + w, y); movie.lineTo(x + w, y + h); movie.lineTo(x, y + h); movie.lineTo(x, y); }} _global.AquaLook.prototype.drawOvalRect = function(movie:MovieClip, x:Number, y:Number, w:Number, h:Number, color:Number, nAlpha:Number, nSize:Number):Void{ var rx:Number = Math.abs(w / 2); var ry:Number = Math.abs(h / 2); this.drawOval(movie, x + rx, y + ry, rx, ry, color, nAlpha, nSize);}_global.AquaLook.prototype.fillOvalRect = function(movie:MovieClip, x:Number, y:Number, w:Number, h:Number, bgCol:Number, bgAlpha:Number, lineCol:Number, lineAlpha:Number):Void{ if(!bgAlpha) bgAlpha = 100; movie.beginFill(bgCol, bgAlpha) this.drawOvalRect(movie, x, y, w, h, lineCol, lineAlpha); movie.endFill();} _global.AquaLook.prototype.drawOval = function(movie:MovieClip, x:Number, y:Number, radius:Number, yRadius:Number, color:Number, nAlpha:Number, nSize:Number):Void{ if (arguments.length < 3) return; if(nSize == undefined || nSize == null) nSize = 1; if(nAlpha == undefined) nAlpha = 100; if(color != null && color != undefined) movie.lineStyle(nSize, color, nAlpha); else movie.lineStyle(null, null, null); // init variables var theta, xrCtrl, yrCtrl, angle, angleMid, px, py, cx, cy:Number; // if only yRadius is undefined, yRadius = radius if (yRadius == undefined) yRadius = radius; // convert 45 degrees to radians for our calculations theta = Math.PI / 4; // calculate the distance for the control point xrCtrl = radius / Math.cos(theta / 2); yrCtrl = yRadius / Math.cos(theta / 2); // start on the right side of the circle angle = 0; movie.moveTo(x + radius, y); // this loop draws the circle in 8 segments for (var i = 0; i < 8; i++) { // increment our angles angle += theta; angleMid = angle - (theta / 2); // calculate our control point cx = x + Math.cos(angleMid) * xrCtrl; cy = y + Math.sin(angleMid) * yrCtrl; // calculate our end point px = x + Math.cos(angle) * radius; py = y + Math.sin(angle) * yRadius; // draw the circle segment movie.curveTo(cx, cy, px, py); }} //// drops drawing routine//_global.AquaLook.prototype.rgb2hsb = function(colRGB:Number):Object{ var red:Number = (colRGB & 0xff0000) >> 16; var gre:Number = (colRGB & 0x00ff00) >> 8; var blu:Number = colRGB & 0x0000ff; var max:Number = Math.max(red, Math.max(gre, blu)); var min:Number = Math.min(red, Math.min(gre, blu)); var hsb:Object = new Object({h:0, s:0, b:Math.round(max * 100 / 255)}); if(max != min) { hsb.s = Math.round(100 * (max - min) / max); var tmpR:Number = (max - red) / (max - min); var tmpG:Number = (max - gre) / (max - min); var tmpB:Number = (max - blu) / (max - min); switch(max) { case red: hsb.h = tmpB - tmpG; break; case gre: hsb.h = 2 + tmpR - tmpB; break; case blu: hsb.h = 4 + tmpG - tmpR; break; } hsb.h = (Math.round(hsb.h * 60) + 360) % 360; } return hsb;}_global.AquaLook.prototype.hsb2rgb = function(hsb:Object):Number{ var red:Number = hsb.b; var gre:Number = hsb.b; var blu:Number = hsb.b; if(hsb.s) { // if not grey var hue:Number = (hsb.h + 360) % 360; var dif:Number = (hue % 60) / 60; var mid1:Number = hsb.b * (100 - hsb.s * dif) / 100; var mid2:Number = hsb.b * (100 - hsb.s * (1 - dif)) / 100; var min:Number = hsb.b * (100 - hsb.s) / 100; switch(Math.floor(hue / 60)) { case 0: red = hsb.b; gre = mid2; blu = min; break; case 1: red = mid1; gre = hsb.b; blu = min; break; case 2: red = min; gre = hsb.b; blu = mid2; break; case 3: red = min; gre = mid1; blu = hsb.b; break; case 4: red = mid2; gre = min; blu = hsb.b; break; default: red = hsb.b; gre = min; blu = mid1; break; } } return Math.round(red * 2.55) * 65536 + Math.round(gre * 2.55) * 256 + Math.round(blu * 2.55);}_global.AquaLook.prototype.ex_brighter = function(rgb, fact) { var FACTOR = fact; var c = this.RGB2Obj(Number(rgb)); var i = Math.ceil(5.0 / (1.0 - FACTOR)); if(c.r == 0 && c.g == 0 && c.b == 0) return this.Obj2RGB({r:i, g:i, b:i}); if ( c.r > 0 && c.r < i ) c.r = i; if ( c.g > 0 && c.g < i ) c.g = i; if ( c.b > 0 && c.b < i ) c.b = i; var ret = {r:Math.min(Math.ceil(c.r/FACTOR), 255), g:Math.min(Math.ceil(c.g/FACTOR), 255), b:Math.min(Math.ceil(c.b/FACTOR), 255)}; return this.Obj2RGB(ret);}_global.AquaLook.prototype.brighter = function(rgb) { return this.ex_brighter(rgb, 0.7);}_global.AquaLook.prototype.RGB2Obj = function(rgb) { var r = (rgb & 0x00ff0000) >>> 16; var g = (rgb & 0x0000ff00) >>> 8; var b = (rgb & 0x000000ff); return { r:r, g:g, b:b };}_global.AquaLook.prototype.Obj2RGB = function(obj) { var rgb = (obj.r << 16) | (obj.g << 8) | obj.b; return rgb;} Object.registerClass('AquaLook', _global.AquaLook);//#endinitclip
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -