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

**URL:** <https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572>\
**Category:** flash\
**Created:** [March 28, 2006, 12:50pm UTC](https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572 "2006-03-28T12:50:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevorsaint](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/trevorsaint/32/268_2.png) [@trevorsaint](https://forum.kirupa.com/u/trevorsaint)\
**Post date:** [March 28, 2006, 12:50pm UTC](https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572/1 "2006-03-28T12:50:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Strength](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@Strength](https://forum.kirupa.com/u/Strength)\
**Post date:** [March 28, 2006, 12:54pm UTC](https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572/2 "2006-03-28T12:54:39Z")

</div>

You mean modifying RGB value?

---

<div class="post-metadata">

**Author:** ![trevorsaint](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/trevorsaint/32/268_2.png) [@trevorsaint](https://forum.kirupa.com/u/trevorsaint)\
**Post date:** [March 28, 2006, 12:59pm UTC](https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572/3 "2006-03-28T12:59:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![serkios](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/serkios/32/608_2.png) [@serkios](https://forum.kirupa.com/u/serkios)\
**Post date:** [March 28, 2006, 11:04pm UTC](https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572/4 "2006-03-28T23:04:53Z")

</div>

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](http://livedocs.macromedia.com/flash/8/main/00001493.html#156519)

---

<div class="post-metadata">

**Author:** ![creatify](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@creatify](https://forum.kirupa.com/u/creatify)\
**Post date:** [March 29, 2006, 1:24am UTC](https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572/5 "2006-03-29T01:24:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![serkios](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/serkios/32/608_2.png) [@serkios](https://forum.kirupa.com/u/serkios)\
**Post date:** [March 29, 2006, 2:02am UTC](https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572/6 "2006-03-29T02:02:25Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![creatify](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@creatify](https://forum.kirupa.com/u/creatify)\
**Post date:** [March 29, 2006, 2:51am UTC](https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572/7 "2006-03-29T02:51:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [March 29, 2006, 3:19am UTC](https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572/8 "2006-03-29T03:19:35Z")

</div>

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. 🙂

I think.

---

<div class="post-metadata">

**Author:** ![trevorsaint](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/trevorsaint/32/268_2.png) [@trevorsaint](https://forum.kirupa.com/u/trevorsaint)\
**Post date:** [March 29, 2006, 9:27am UTC](https://forum.kirupa.com/t/control-tint-via-actionscript-any-idea-how-to-achieve-this/183572/9 "2006-03-29T09:27:36Z")

</div>

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
