# May anyone tell me what the following codes means?

**URL:** <https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053>\
**Category:** flash\
**Created:** [August 30, 2002, 12:45am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053 "2002-08-30T00:45:15Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![imagebear](https://avatars.discourse-cdn.com/v4/letter/i/e19adc/32.png) [@imagebear](https://forum.kirupa.com/u/imagebear)\
**Post date:** [August 30, 2002, 12:45am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/1 "2002-08-30T00:45:15Z")

</div>

swatchColor.setRGB(\_root[“r”+myNum+“Change”]\<\< 16 | \_root[“g”+myNum+“Change”] \<\< 8 |

```
       _root["b"+myNum+"Change"]);

```

Who can tell me how it works?

THKS!

---

<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:** [August 30, 2002, 1:23am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/2 "2002-08-30T01:23:54Z")

</div>

It means nothing alone. What it looks like it does is sets the color of a movie clip called swatchColor to a hex RGB value using the variable myNum.

Why do you need to know? Do you have the rest of the script?

---

<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:** [August 30, 2002, 1:35am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/3 "2002-08-30T01:35:13Z")

</div>

Ok,please look here:  
[RandomColor](http://www.kirupa.com/developer/flash5/randomcolor.asp)

I see the tutorial in [kirupa.com](http://kirupa.com),but I don’t know how it works.Can you commentate that?

THKS for your reply

---

<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:** [August 30, 2002, 2:01am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/4 "2002-08-30T02:01:07Z")

</div>

I will see what I can do.

\<B\>myNum = \_name\</B\> - Gets the name of the movie clip that you want the color to change. In the downloadable file, kirupa gave each movie clip an instance name of a number (1,2,3,4, in order like that). Since the names are numbers, they can be set as variables.

\<B\>“r”+myNum+“Change”\</B\> - reads r, then adds the instance name number, then reads Change. r would be red, g would be green, and b would be blue (the three colors of RGB values, hence the name RGB).

\<B\>swatchColor = new Color(this);\</B\> - Tells it to change this RGB color.

\<B\>swatchColor.setRGB(\_root[“r”+myNum+“Change”] \<\< 16 | \_root[“g”+myNum+“Change”] \<\< 8 | \_root[“b”+myNum+“Change”]);\</B\> - Get an R value, a G value and a B value and change the color of this clip.

Everything after that tells it to use the old RGB value and slowly fade the new color in.

I am just about THE worst person to explain things, so I probably just confused you more here. It doesn’t help that I don’t FULLY understand the code. Either way, I hope I helped at least a little tiny bit.

---

<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:** [August 30, 2002, 2:24am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/5 "2002-08-30T02:24:27Z")

</div>

OK,you help me a lot!

But I really don’t know how the following works,who can tell me how does the ’ [COLOR=red]\<\<[/COLOR] ’ and ’ [COLOR=red]|[/COLOR] ’ works?

## code:

## [COLOR=darkred]\_root[“r”+myNum+“Change”] \<\< 16 | \_root[“g”+myNum+“Change”] \<\< 8 | \_root[“b”+myNum+“Change”] [/COLOR]

---

<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:** [August 30, 2002, 2:42am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/6 "2002-08-30T02:42:22Z")

</div>

They are called bitwise operators.

\<B\> “\<\<” \</B\> Converts and number to binary and shifts a number to the left.  
So the number on the left of the \<\< is the number to be shifted and the number on the right of the \<\< is how many spots to be shifted (spots use 0’s in place).  
\<I\>EXAMPLE\</I\> = 1 \<\< 0 = 1, but 1 \<\< 10 = 1024 or 10000000000 in binary, which eqauls 1024 (1+10 0’s)

\<B\>|\</B\> Another bitwise operator. I am not exactly sure what this statement does. I think this converts a number into binary form, then combines the 2 numbers’ binary string and creates a new number. Kind of like combining DNA strands or something. Like I said, I am not exactly sure what it does, I am just taking a guess, but I have tried different things and it seems like that is what it does.

Another one of my worst explanations ever, but if something is unclear, just let me know. I will see if I can elaborate on it.

---

<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:** [August 30, 2002, 4:33am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/7 "2002-08-30T04:33:47Z")

</div>

Macromedia runs a quick reference online. Might be helpful.

[http://www.macromedia.com/support/flash/action\_scripts/bitwise\_right\_shift.html](http://www.macromedia.com/support/flash/action_scripts/bitwise_right_shift.html)

[http://www.macromedia.com/support/flash/action\_scripts/bitwise\_or.html](http://www.macromedia.com/support/flash/action_scripts/bitwise_or.html)

---

<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:** [August 30, 2002, 4:36am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/8 "2002-08-30T04:36:28Z")

</div>

Thanks david, it was driving me nuts how to put it in words. Was I even close with my descriptions?

---

<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:** [August 30, 2002, 4:58am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/9 "2002-08-30T04:58:19Z")

</div>

not sure. You’re \<\< example seemed correct to me… but I’ve never used that. | is a bitwise “or” operator.

"Operator (bitwise); converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1. "

now I’ve only used the or to differentiate in “if” statements… so I’m not sure how that relates.

---

<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:** [August 30, 2002, 5:24am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/10 "2002-08-30T05:24:07Z")

</div>

The | operator seemed to do what I described it to do. For an example I used the binary codes 11100 and 00011 and it came out in the end as 11111.

And if I did 1010 | 0101 it came out 1111. Like it just merged the two strings.

---

<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:** [August 30, 2002, 6:04am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/11 "2002-08-30T06:04:34Z")

</div>

Thks you two,I understand now.

Color code is 24 bitwise,Such as #ffffff

if r = xx,then r\<\<16,it becomes xx0000,it appears at the place shows the red part,then green and blue is same

then xx0000|00yy00|00zz00=xxyyzz  
r=xx,g=yy,b=zz

That’s the result!

Sorry for my bad English!

---

<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:** [August 30, 2002, 6:07am UTC](https://forum.kirupa.com/t/may-anyone-tell-me-what-the-following-codes-means/5053/12 "2002-08-30T06:07:38Z")

</div>

And voila you have your Random RGB Fade. Glad we could help you out imagebear:)

Your English is great, I have known people that could speak perfect english but could type such bad english that you had to ask them what they meant all the time.

And well, your english is better than my (whatever language you originally speak). Ok so I stole that from a post I saw somewhere else on this forum, but it is true none the less.
