Control tint via actionscript, any idea how to achieve this?

Hi all,

does anyone know how to set the TINT not the colour of an object using actionscript.

I can set the alpha no problem, i.e

[AS]

function over() {
this._alpha = 100;
}

function out() {
this._alpha = 70;
}

[/AS]

But is there a way in achiving a tint instead of an alpha?

Cheers

Trev

You mean modifying RGB value?

Nope, its not the colour I need to change but the tint, I am not sure if these relate, if I say wanted a 50% white tint, how would I achieve this.

Manually I can, but I need in on a mouse over and out script.

i.e on rollover change tint to 0%

on rollout chance tint to 50%

Hope this makes sense

Cheers

With Flash 8 you need to use the ColorTransform and Transform classes. You could also use the Color class (but I think its depreciated now). Here’s a link to get you started with the Flash 8 method:

http://livedocs.macromedia.com/flash/8/main/00001493.html#156519

These are some methods I created for a larger class but, it does tint a movieclip - the thing I like about the method is that you can pass it a hex color (0x339999 for example) and it returns a hex value - so that value can be used to color clips, text or whatever - many I’ve found have built in mc color functionality, which is great if only coloring mcs, but not great for coloring other items or using a hex in a loop to get an incremented color tint. Hope it helps,

Creatify

Nice code creatify. Could you possibly tell me how this code works? Not real familiar with how those operators work to return the hex number

function rgbToHex(r,g,b) {
	return(r<<16 | g<<8 | b);
}

Good question - I have gathered that code originally, I think, from Colin Moock. From what I know of them, they’re all bitwise operators - they take any interger and convert them into 32-bit intergers. the “Or” operator ("|") almost acts as a recursion to string together the separate r g b intergers, into a hex number (ultimately turning the 3 interger r g b values into individual hex values (0-9, a-f)). Mathmatically, I don’t know how this ends up to hexadecimal.

I’m not sure either, but the << will convert it to binary, then move the numbers over to the left the designated number of times. Like this:

8<<1 equals 001000<<1 which would produce 010000… 16. :slight_smile:

I think.

Thanks for all your feedback, woa a lot of code, I will have a look at this later today and see if I can get it to work.

Thanks a lot :).

Trev