Posted By

dhjapan on 03/03/08


Tagged

color


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dazza


setColor


 / Published in: ActionScript
 

  1. import flash.geom.Transform;
  2. import flash.geom.ColorTransform;
  3.  
  4. ...
  5.  
  6.  
  7. // sets color to each rowList[i].bg movieClip
  8. // initColor if this color has to be the default color
  9. private function setColor(target:MovieClip, color:String, init_color:Boolean) {
  10.  
  11. if (color.substr(0, 1) == "#") color = color.substr(1);
  12. var _r = (color != undefined) ? "0x" + color.substr(0, 2) : 0;
  13. var _g = (color != undefined) ? "0x" + color.substr(2, 2) : 0;
  14. var _b = (color != undefined) ? "0x" + color.substr(4, 2) : 0;
  15.  
  16. var t = new Transform(mc);
  17.  
  18. if (bg != undefined) var new_ct = new ColorTransform(0, 0, 0, 0, _r, _g, _b, 255);
  19. else var new_ct = mc.init_color;
  20.  
  21. t.colorTransform = new_ct;
  22.  
  23. // keeps default colorTransform when needed
  24. if (init_color) mc.init_color = new_ct;
  25.  
  26. }

Report this snippet  

You need to login to post a comment.