[Extendflash] converting fill color to tint
Morten Barklund Shockwaved
morten.barklund at shockwaved.com
Sat Aug 6 00:36:00 PDT 2005
> How can I convert a fill hexadecimal color to color transform data?
>
> I'm trying to iterate through about 700 movieclips and change their
> movieclips tint to equal the movieclips fill color.
Hi Erik,
I've made a little script, which does what you say.
It asumes a lot of things. First of all, all your elements are placed in
frame 1 of layer 1 of scene 1. Second of all, all your movieclips
contain only a simple shape (without any outline or anything) which is
placed within the movieclip in frame 1 of layer 1.
If that is so, the following should work:
var dom = fl.getDocumentDOM();
var elements = dom.getTimeline().layers[0].frames[0].elements;
var i, e, c;
for (i = 0; i < elements.length; i++) {
e = elements[i];
if (e.elementType == "instance") {
dom.library.editItem(e.libraryItem.name);
dom.selectAll();
c = parseInt(dom.getCustomFill().color.slice(2,-1),16);
dom.editScene(0);
e.colorRedAmount = (c & 0xFF0000) >> 16;
e.colorGreenAmount = (c & 0xFF00) >> 8;
e.colorBlueAmount = (c & 0xFF);
e.colorRedPercent = 0;
e.colorGreenPercent = 0;
e.colorBluePercent = 0;
}
}
Well, it isn't nice, but it's quite simple :)
Hope that helps you on the way.
--
Morten Barklund - Information Architect - Shockwaved ApS
Larsbjoernsstraede 8 - DK-1454 Copenhagen K, Denmark
Phone: +45 7027 2227 - Fax: +45 3369 1174
More information about the Extendflash
mailing list