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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Color Object help please

Status
Not open for further replies.

amaliat

IS-IT--Management
Nov 3, 2003
2
GB
hello
i am sure you know the color picker sample from the flash samples (
I want to have 2 sets of sliders, and 2 preview boxes, so i can change their colours individually.

This is what i have so far. Only the second part of the script, for the second slider, works. Can you please tell me why? it's something with the function, there seems to be some conflict and overwriting going on...

thank you
amalia



// create colors
color1 = new Color(screenbox);
//
this.onEnterFrame = function() {
// set c1, c2, c3, hc1, hc2, and hc3 equal to the positions of their respective faders and vice versa
for (i=1; i<=3; i++) {
this[&quot;color&quot;+1].setRGB(rgb);
this[&quot;hexc&quot;+i+&quot;Text&quot;].onKillFocus = function() {
hexMode = false;
};
this[&quot;hexc&quot;+i+&quot;Text&quot;].onSetFocus = function() {
hexMode = true;
};
slider = this[&quot;slider&quot;+i].cap;
if (dragging) {
this[&quot;c&quot;+i] = slider._y;
this[&quot;hc&quot;+i] = this[&quot;c&quot;+i].toString(16);
} else {
if (hexMode) {
slider._y = parseInt(&quot;0x&quot;+this[&quot;hc&quot;+i]);
this[&quot;c&quot;+i] = parseInt(&quot;0x&quot;+this[&quot;hc&quot;+i]);
} else {
slider._y = this[&quot;c&quot;+i];
this[&quot;hc&quot;+i] = Number(this[&quot;c&quot;+i]).toString(16);
if (this[&quot;c&quot;+i]>255) {
this[&quot;c&quot;+i] = 255;
}
}
}
}
//
// combine c1, c2, and c3 into one variable using bitwise left shift and bitwise OR
rgb = (c1 << 16 | c2 << 8 | c3);
};
// create colors
color2 = new Color(previewbox);
//
this.onEnterFrame = function() {
// set c1, c2, c3, hc1, hc2, and hc3 equal to the positions of their respective faders and vice versa
for (i=1; i<=3; i++) {
this[&quot;color&quot;+2].setRGB(rgb);
this[&quot;hexc&quot;+i+&quot;Text&quot;].onKillFocus = function() {
hexMode = false;
};
this[&quot;hexc&quot;+i+&quot;Text&quot;].onSetFocus = function() {
hexMode = true;
};
fader = this[&quot;fader&quot;+i].knob;
if (dragging) {
this[&quot;c&quot;+i] = fader._y;
this[&quot;hc&quot;+i] = this[&quot;c&quot;+i].toString(16);
} else {
if (hexMode) {
fader._y = parseInt(&quot;0x&quot;+this[&quot;hc&quot;+i]);
this[&quot;c&quot;+i] = parseInt(&quot;0x&quot;+this[&quot;hc&quot;+i]);
} else {
fader._y = this[&quot;c&quot;+i];
this[&quot;hc&quot;+i] = Number(this[&quot;c&quot;+i]).toString(16);
if (this[&quot;c&quot;+i]>255) {
this[&quot;c&quot;+i] = 255;
}
}
}
}
//
// combine c1, c2, and c3 into one variable using bitwise left shift and bitwise OR
rgb = (c1 << 16 | c2 << 8 | c3);
};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top