Developer Forums / Programming

Color changing


Robbit3 months ago | Post #1
0 points
I want to let the user choose the color of some movieclips, so I made the movieclips black and white colored. Now i need a code that does the same trick
as the "advanced" tab does for coloring at the properties. "Tint" doesn't work, since I lose the differences between dark and light then.

So, is there an AS2 function what does the same as the "advanced" coloring tab under the MovieClips properties?
Mystery3 months ago | post #2, in reply to #1
0 points
use the ColorTransform object to apply 'advanced' coloring to movieclips,


import flash.geom.*

var c:ColorTransform = new ColorTransform();
c.redMultiplier = 0;
c.redOffset = 0;
c.greenMultiplier = 0;
c.greenOffset = 0;
c.blueMultiplier = 0;
c.blueOffset = 0;
c.alphaMultiplier = 0;
c.alphaOffset = 127;

mc1.transform.colorTransform = c;


colors the movieclip mc1 black with 50% alpha.
4043 months ago | post #3, in reply to #1
0 points
That looks like as3 to me, Mystery.


To answer your question Robbit, no, there's not rally any easy way to do what you are wanting to do in AS2.

var c = new Color(_root.mc);
c.setRGB("0xFF9900");
//this is just off the top of my head, I don't know if the syntax is correct...

Will set the tint of your mc using actionscript, but it doesn't have a handy percentage like the "tint" option you mentioned.


I would suggest creating a movie clip of the different things you need colored inside your other movie clip and then setting the color of the movieclip on the inside.
4043 months ago | post #4, in reply to #3
0 points
"not rally any"

should obviously be

"not really any"

I hate hate hate hate typos...
Mystery3 months ago | post #5, in reply to #3
0 points
I'm pretty sure I have my publish settings to as2 when I tested that. You can also check the help files to verify that that is as2.
Robbit3 months ago | post #6, in reply to #1
0 points
I used 404's way ^^

thanks
cbeech3 months ago | post #7, in reply to #1
0 points
404 - Mystery is correct, it is AS2 - in fact the ColorTransform class has been available since AS1 even, however a more common syntax is:

var c = new ColorTransform(0,0,0,1,0,0,0,0); //black

Additionally, the setRGB() method is being Deprecated as of FP8, and you may want to work on making the transfer from the 'Color' class to the ColorTransform class methods. further, you would not declare the hex parameter as a string in the setRGB() method.

Reply to thread

Sign up now to reply to threads

 
NONOBA-WEB2