# Colour changing effect in Rev's footer

**URL:** https://forum.kirupa.com/t/colour-changing-effect-in-revs-footer/34403
**Category:** flash
**Created:** [November 1, 2003, 6:38pm UTC](https://forum.kirupa.com/t/colour-changing-effect-in-revs-footer/34403 "2003-11-01T18:38:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ranoka](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ranoka/32/265_2.png) [@Ranoka](https://forum.kirupa.com/u/Ranoka)
#### Post date: [November 1, 2003, 6:38pm UTC](https://forum.kirupa.com/t/colour-changing-effect-in-revs-footer/34403/1 "2003-11-01T18:38:33Z")

</div>

Hi all,

I was just wondering how Rev did the colour changing effect in his current footer?

Reminds me of my ZX Spectrum games, and I wan’t to play around with this effect.

I assume there is actionscript code involved in this effect?

Cheers 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 1, 2003, 7:06pm UTC](https://forum.kirupa.com/t/colour-changing-effect-in-revs-footer/34403/2 "2003-11-01T19:06:30Z")

</div>

I got it from a thread that Ilyas made, where he stated that he ‘borrowed’ it from Bit-101’s site.

so, you can do a search for it here, or go straight to the source, Bit-101 …

Rev ![](http://aulman.com/rev.gif)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 2, 2003, 11:10am UTC](https://forum.kirupa.com/t/colour-changing-effect-in-revs-footer/34403/3 "2003-11-02T11:10:26Z")

</div>

Cycling colors tutorial: :beam:

First, create a dot:

```auto
this.createEmptyMovieClip ( "myClip", 0 ) ;
myClip.lineStyle ( 30, 0, 100 ) ;
myClip.lineTo ( .45, .15 ) ;

```

Then create the color cycle:

```auto
// Create a color object corresponding to the clip you want to apply setRGB to
myClip.colorClip = new Color ( myClip ) ;

myClip.onEnterFrame = function () {
	var r = 128 * ( 1 + Math.cos ( ra += .03 ) ) ;
	var g = 128 * ( 1 + Math.cos ( rg += .05 ) ) ;
	var b = 128 * ( 1 + Math.cos ( rb += .01 ) ) ;
	var myColor = r << 16 | g << 8 | b ;
	this.colorClip.setRGB ( myColor ) ;
}

```

The tricky part is in the onEnterFrame.  
[FONT=courier new]var r = 128 \* ( 1 + Math.cos ( ra += .03 ) ) ;[/FONT]  
for instance, will return a number between 0 and 256, which is pretty much what we want since color components (green, red and blue) go from 0 to 255 (0 to FF in hexadecimal), 0 being ‘no color’ and 255 (or FF) being ‘full color’.

The Math.cos part does the cycling, because that function (just like Math.sin) returns cycling values between -1 and 1 (it’s a circular function).

Once we’ve calculated the 3 components of our color (r, g, b), we put them together with this very nice line:  
[FONT=courier new]var myColor = r \<\< 16 | g \<\< 8 | b ;[/FONT]  
It has to be in this order: Red, then Green, and then Blue, as in RGB. The \<\< and | operators are bitwise operators, and they allow you to shift your color values properly, and then stick them together.

Tadaaa!! Finished 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 13, 2003, 11:37pm UTC](https://forum.kirupa.com/t/colour-changing-effect-in-revs-footer/34403/4 "2003-11-13T23:37:52Z")

</div>

Thanks Ilyas!

Sorry I didn’t thank you earlier, but I only just checked the thread.

I’ve just started learning Actionscript. My tutor just the other day showed me cycles using cos and sin, so I understand the code!

Thanks again! I’m going to have a play around now 🙂
