Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hex Converter

Status
Not open for further replies.

Nukoi

Programmer
Dec 20, 2001
82
US
Hey fellas. This is something from a long long time ago that I wrote and I could never figure out why it wouldnt work. It converts RGB decimal values(0-255) into hex(00-FF).. Well its supposed to anyways. =) The problem is that if I get to what should be "A0" in hex, it goes to "100" .. I can turn the right digit to hex but it won't let me change the left. Anyways here is the script.. I realize it isnt a terribly efficient way to do this but I was a newbie at the time =).


val = Math.round((slider._x-8)/16);
if (sliderval<_parent.a) {
val2 = new String(val);
} else {
if (val==_parent.a) {
val2 = new String(&quot;a&quot;);
} else if (val==_parent.b) {
val2 = new String(&quot;b&quot;);
} else if (val==_parent.c) {
val2 = new String(&quot;c&quot;);
} else if (val==_parent.d) {
val2 = new String(&quot;d&quot;);
} else if (val==_parent.e) {
val2 = new String(&quot;e&quot;);
} else if (val==_parent.f) {
val2 = new String(&quot;f&quot;);
}
}
val3 = Math.round(slider._x)%16;
if (val3<_parent.a) {
val4 = new String(val3);
} else {
if (val3==_parent.a) {
val4 = new String(&quot;a&quot;);
} else if (val3==_parent.b) {
val4 = new String(&quot;b&quot;);
} else if (val3==_parent.c) {
val4 = new String(&quot;c&quot;);
} else if (val3==_parent.d) {
val4 = new String(&quot;d&quot;);
} else if (val3==_parent.e) {
val4 = new String(&quot;e&quot;);
} else if (val3==_parent.f) {
val4 = new String(&quot;f&quot;);
}
}
final = new String(val2+val4);

(there are 3 instances of this movie clip for R-G-B)

Thanks in advance guys (and girls)

-Nukoi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top