May anyone tell me what the following codes means?

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

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

Who can tell me how it works?

THKS!

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?

Ok,please look here:
RandomColor

I see the tutorial in kirupa.com,but I don’t know how it works.Can you commentate that?

THKS for your reply

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.

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]

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.

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_or.html

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

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.

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.

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!

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.