📄 xplook.as
字号:
this.drawLine(mc, x + size2 + dX, y + size2 - 2*dY, x + size - dX, y, clr, alpha); this.drawLine(mc, x + size2 + dX, y + size2 - dY, x + size - dX, y + dY, clr, alpha); this.drawLine(mc, x + size2, y + size2 - 2*dY, x + size - 2*dX, y, clr, alpha); mc._width = 0.5*nW; mc._height = 0.5*nH;}_global.XPLook.prototype.drawComboBoxBtn = function(movie:MovieClip, nW:Number, nH:Number, data:Object):Void{ this.drawScrollLayer(movie, nW, nH, {mode:data.mode, dir:"vert", type:data.pLink.BTN_TYPE_SCROLL_HI, pLink : data.pLink, clr : data.clr});}_global.XPLook.prototype.drawComboBox = function(movie:MovieClip, nW:Number, nH:Number, data:Object):Void{ movie.clear(); switch(data.mode) { default: movie.lineStyle(1, globalStyleFormat[data.pLink._backgroundBorder], 100); movie.beginFill(data.clr, 100); this.drawFillRect(movie, 0.5, 0.5, nW - 1, nH - 1); movie.endFill(); movie.lineStyle(undefined); break; }}_global.XPLook.prototype.drawRect = function(movie:MovieClip, nX:Number, nY:Number, nW:Number, nH:Number, nColor:Number, nAlpha:Number):Void{ if(!nColor) nColor = 0; if(nAlpha == undefined || nAlpha == null) nAlpha = 100; with(movie) { beginFill(nColor, nAlpha); moveTo(nX, nY); lineTo(nX + nW, nY); lineTo(nX + nW, nY + nH); lineTo(nX, nY + nH); lineTo(nX, nY); endFill(); }}_global.XPLook.prototype.drawLine = function(movie:MovieClip, x1:Number, y1:Number, x2:Number, y2:Number, clr:Number, alpha:Number):Void{ var dx:Number = Math.abs(x2 - x1); var dy:Number = Math.abs(y2 - y1); var sx:Number = x2 >= x1 ? 1 : -1; var sy:Number = y2 >= y1 ? 1 : -1; this.drawRect(movie, x1, y1, 1, 1, clr, alpha); if(dy <= dx) { var d1:Number = dy << 1; var d:Number = d1 - dx; var d2:Number = ( dy - dx ) << 1; var x:Number = x1 + sx; var y:Number = y1; for(var i:Number = 1; i <= dx; i++) { if (d > 0) { d += d2; y += sy; } else d += d1; this.drawRect(movie, x, y, 1, 1, clr, alpha); x += sx; } } else { var d1:Number = dx << 1; var d:Number = d1 - dy; var d2:Number = (dx - dy) << 1; var x:Number = x1; var y:Number = y1 + sy; for (var i:Number = 1; i <= dy; i++) { if( d > 0) { d += d2; x += sx; } else d += d1; this.drawRect(movie, x, y, 1, 1, clr, alpha); y += sy; } }} _global.XPLook.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.XPLook.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); }} //// drops drawing routine//_global.XPLook.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.XPLook.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.XPLook.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.XPLook.prototype.ex_darker = function(rgb, fact) { var FACTOR = fact; var c = this.RGB2Obj(rgb); var ret = {r:Math.max(Math.ceil(c.r*FACTOR), 0), g:Math.max(Math.ceil(c.g*FACTOR), 0), b:Math.max(Math.ceil(c.b*FACTOR), 0)}; return this.Obj2RGB(ret);}_global.XPLook.prototype.brighter = function(rgb) { return this.ex_brighter(rgb, 0.7);}_global.XPLook.prototype.darker = function(rgb) { return this.ex_darker(rgb, 0.7);}_global.XPLook.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.XPLook.prototype.Obj2RGB = function(obj) { var rgb = (obj.r << 16) | (obj.g << 8) | obj.b; return rgb;} Object.registerClass('XPLook', _global.XPLook);//#endinitclip
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -