// --- FCColor.as --- // /* --------------------------------------------------------------------------------- This file adds a few new functions to the base Color object. All the functions contained in this file can be used with any other Flash 5+ movie for working with deeper/lighter shades of color The base object in this file is Color --------------------------------------------------------------------------------- Sample Usage for the setDarkColor function: myclr = new Color("MovClipName"); myclr.setDarkColor("FF0000", 0.80); --------------------------------------------------------------------------------- */ Color.prototype.setDarkColor = function(sourceHexColor, intensityRequired) { // This function sets a darker color for the specified object // Based on the intensity specified //First format the hexcolor to trim the # and leading spaces sourceHexColor = _root.Functions.formatHexColor(sourceHexColor); //Format the color in RGB notation sourceclrRGB = parseInt(sourceHexColor, 16); //Now, get the r,g,b values separated out of the specified color var r = Math.floor(sourceclrRGB/65536); var g = Math.floor((sourceclrRGB-r*65536)/256); var b = sourceclrRGB-r*65536-g*256; //Now, get the darker color based on the Intesity Specified darkColor = (r*intensityRequired) << 16 | (g*intensityRequired) << 8 | (b*intensityRequired); this.setRGB(darkColor); }; Color.prototype.setLightColor = function(sourceHexColor, intensityRequired) { // This function sets a lighter color for the specified object // Based on the intensity specified //First format the hexcolor to trim the # and the leading spaces sourceHexColor = _root.Functions.formatHexColor(sourceHexColor); //Format the color in RGB notation sourceclrRGB = parseInt(sourceHexColor, 16); //Now, get the r,g,b values separated out of the specified color var r = Math.floor(sourceclrRGB/65536); var g = Math.floor((sourceclrRGB-r*65536)/256); var b = sourceclrRGB-r*65536-g*256; //Now, get the lighter color based on the Intesity Specified lightColor = (256-((256-r)*intensityRequired)) << 16 | (256-((256-g)*intensityRequired)) << 8 | (256-((256-b)*intensityRequired)); this.setRGB(lightColor); }; Color.prototype.setTint = function(sourceHexColor, intensityRequired) { //This function sets a tint of a specific color //Based on the intensity specified //First format the hexcolor to trim the # and the leading spaces sourceHexColor = _root.Functions.formatHexColor(sourceHexColor); //Format the color in RGB notation sourceclrRGB = parseInt(sourceHexColor, 16); //Now, get the r,g,b values separated out of the specified color var r = Math.floor(sourceclrRGB/65536); var g = Math.floor((sourceclrRGB-r*65536)/256); var b = sourceclrRGB-r*65536-g*256; var trans = new Object(); trans.ra = trans.ga=trans.ba=100-intensityRequired; var ratio = intensityRequired/100; trans.rb = r*ratio; trans.gb = g*ratio; trans.bb = b*ratio; this.setTransform(trans); };