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["color"+1].setRGB(rgb);
this["hexc"+i+"Text"].onKillFocus = function() {
hexMode = false;
};
this["hexc"+i+"Text"].onSetFocus = function() {
hexMode = true;
};
slider = this["slider"+i].cap;
if (dragging) {
this["c"+i] = slider._y;
this["hc"+i] = this["c"+i].toString(16);
} else {
if (hexMode) {
slider._y = parseInt("0x"+this["hc"+i]);
this["c"+i] = parseInt("0x"+this["hc"+i]);
} else {
slider._y = this["c"+i];
this["hc"+i] = Number(this["c"+i]).toString(16);
if (this["c"+i]>255) {
this["c"+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["color"+2].setRGB(rgb);
this["hexc"+i+"Text"].onKillFocus = function() {
hexMode = false;
};
this["hexc"+i+"Text"].onSetFocus = function() {
hexMode = true;
};
fader = this["fader"+i].knob;
if (dragging) {
this["c"+i] = fader._y;
this["hc"+i] = this["c"+i].toString(16);
} else {
if (hexMode) {
fader._y = parseInt("0x"+this["hc"+i]);
this["c"+i] = parseInt("0x"+this["hc"+i]);
} else {
fader._y = this["c"+i];
this["hc"+i] = Number(this["c"+i]).toString(16);
if (this["c"+i]>255) {
this["c"+i] = 255;
}
}
}
}
//
// combine c1, c2, and c3 into one variable using bitwise left shift and bitwise OR
rgb = (c1 << 16 | c2 << 8 | c3);
};
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["color"+1].setRGB(rgb);
this["hexc"+i+"Text"].onKillFocus = function() {
hexMode = false;
};
this["hexc"+i+"Text"].onSetFocus = function() {
hexMode = true;
};
slider = this["slider"+i].cap;
if (dragging) {
this["c"+i] = slider._y;
this["hc"+i] = this["c"+i].toString(16);
} else {
if (hexMode) {
slider._y = parseInt("0x"+this["hc"+i]);
this["c"+i] = parseInt("0x"+this["hc"+i]);
} else {
slider._y = this["c"+i];
this["hc"+i] = Number(this["c"+i]).toString(16);
if (this["c"+i]>255) {
this["c"+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["color"+2].setRGB(rgb);
this["hexc"+i+"Text"].onKillFocus = function() {
hexMode = false;
};
this["hexc"+i+"Text"].onSetFocus = function() {
hexMode = true;
};
fader = this["fader"+i].knob;
if (dragging) {
this["c"+i] = fader._y;
this["hc"+i] = this["c"+i].toString(16);
} else {
if (hexMode) {
fader._y = parseInt("0x"+this["hc"+i]);
this["c"+i] = parseInt("0x"+this["hc"+i]);
} else {
fader._y = this["c"+i];
this["hc"+i] = Number(this["c"+i]).toString(16);
if (this["c"+i]>255) {
this["c"+i] = 255;
}
}
}
}
//
// combine c1, c2, and c3 into one variable using bitwise left shift and bitwise OR
rgb = (c1 << 16 | c2 << 8 | c3);
};