home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 July / com!online0702.iso / software / livemotion / DATA1.CAB / Include / swfColor.js < prev    next >
Encoding:
Text File  |  2002-05-13  |  3.4 KB  |  149 lines

  1. /***************************************************************
  2. ADOBE SYSTEMS INCORPORATED 
  3. Copyright 2002 Adobe Systems Incorporated 
  4. All Rights Reserved 
  5.  
  6. NOTICE:  Adobe permits you to use, modify, and distribute this 
  7. file in accordance with the terms of the Adobe license agreement 
  8. accompanying it.  If you have received this file from a source 
  9. other than Adobe, then your use, modification, or distribution
  10. of it requires the prior written permission of Adobe. 
  11. ***************************************************************/
  12. /***************************************************************
  13. Author: Ken Villines
  14. ***************************************************************/
  15.  
  16. /***************************************************************
  17.  
  18. This is an include file to be used with Scripting swf export.
  19.  
  20. These functions make using the Color Object a little easier. The file
  21. should be included in the compositions onload handler. The code below
  22. shows how to include the file:
  23.  
  24. #include "Include/swfColor.js"
  25.  
  26.  
  27. *********Function Definitions***************
  28.  
  29.  
  30. this.setColor(red, green, blue)
  31.  
  32. red = 0-255
  33. green = 0-255
  34. blue = 0-255
  35.  
  36. returns the value of the new color
  37.  
  38.  
  39. this.setTransColor(redA, redB, greenA, greenB, blueA, blueB, alphaA, alphaB)
  40.  
  41. redA = 0-255
  42. redB = 0-255
  43. greenA = 0-255
  44. greenB = 0-255
  45. blueA = 0-255
  46. blueB = 0-255
  47. alphaA = 0-255
  48. alphaB = 0-255
  49.  
  50. returns the value of the new Transform color
  51.  
  52. this.getColor(colorToGet)
  53.  
  54. colorToGet = takes a string ("red", "green", or "blue") 
  55. returns the value of the color specified
  56.  
  57.  
  58. this.getHexColor()
  59.  
  60. returns the Hex color value of the movie clip specified
  61.  
  62.  
  63. this.getTransColor(colorToGet)
  64.  
  65. colorToGet = one of the 8 advanced color properties from setTransColor
  66. returns the color value of the property handed to the function
  67.  
  68. ***************************************************************/
  69.  
  70. /***************************************************************
  71. DO NOT EDIT BELOW THIS LINE
  72. ***************************************************************/
  73.  
  74.  
  75. MovieClip.prototype.setColor = function (red, green, blue)
  76. {
  77. var theValue = red*65536+green*256+blue;
  78.  
  79. theNewColor = new Color(this)
  80.  
  81. theNewColor.setRGB(theValue);
  82. }
  83.  
  84.  
  85.  
  86. MovieClip.prototype.setTransColor = function(redA, redB, greenA, greenB, blueA, blueB, alphaA, alphaB)
  87. {
  88. transColorObj = new Object()
  89. transColorObj.ra = redA;
  90. transColorObj.rb = redB;
  91. transColorObj.ga = greenA;
  92. transColorObj.gb = greenB;
  93. transColorObj.ba = blueA;
  94. transColorObj.bb = blueB;
  95. transColorObj.aa = alphaA;
  96. transColorObj.ab = alphaB;
  97.  
  98. theTransColor = new Color(this)
  99.  
  100. theTransColor.setTransform(transColorObj);
  101. }
  102.  
  103.  
  104. MovieClip.prototype.getColor = function(colorToGet)
  105. {
  106.  
  107. theNewColor = new Color(this)
  108.  
  109. theColor = theNewColor.getRGB();
  110.  
  111.     if(colorToGet=="red")
  112.     {
  113.     redNum = (theColor>>16) & 0xFF;
  114.     return redNum;
  115.     }
  116.     else if (colorToGet=="green")
  117.     {
  118.     greenNum = (theColor>>8) & 0xFF;
  119.     return greenNum;
  120.     }
  121.     else if (colorToGet=="blue")
  122.     {
  123.     blueNum = theColor & 0xFF;
  124.     return blueNum;
  125.     }
  126. }
  127.  
  128.  
  129. MovieClip.prototype.getHexColor = function()
  130. {
  131.  
  132. theNewColor = new Color(this)
  133.  
  134. theColor = theNewColor.getRGB().toString(16);
  135.  
  136. return theColor;
  137. }
  138.  
  139.  
  140. MovieClip.prototype.getTransColor = function(colorToGet)
  141. {
  142.  
  143. theNewColor = new Color(this)
  144.  
  145. theColor = theNewColor.getTransform();
  146.  
  147. return theColor[colorToGet];
  148. }
  149.