Hello everyone, thanks for all your previous help!
This is a tough one for me…I’ve been trying to create a function that I can call to change the color of serveral movies clips simultaneously. I want to simply pass the old color and the destination color and point the function to the appropriate mc.
The function below works, but only the first time it is called. With the second call, I can see that the function is receiving the arguments correctly, but the left movieclip stays the same color.
Perhaps I’m not understanding the color object correctly, or perhaps I can’t make simultaneous calls to the same function. Any ideas how to solve this problemo? Thanks!
ALSO, what would be the correct syntax to delete the OnEnterFrame in the fade_color function? I need to make sure that all three colors have reach their destinations.
Thanks!!!
Here’s the code:
// two moviesclips, each containing a black shape, called mc_r and mc_l
var mycolor_r = new Color(mc_r);
var mycolor_l = new Color(mc_l);
// set initial desired color
var change_r = {rb:169,gb:195,bb:217};
var change_l = {rb:91,gb:108,bb:133};
//transform black mc's to initial desired color OnLoad
mycolor_r.setTransform(change_r);
mycolor_l.setTransform(change_l);
// trigger color change
button.onRelease = function() {
//set the destination color for r & l mc's
var red_dest_r = 219;
var green_dest_r = 201;
var blue_dest_r = 174;
var red_dest_l = 180;
var green_dest_l = 157;
var blue_dest_l = 125;
// call fade_color function twice, once for mc_r, once for mc_l, pass destination rgb and instance name and original color
fade_color(red_dest_r, green_dest_r, blue_dest_r, "mc_r", change_r);
fade_color(red_dest_l, green_dest_l, blue_dest_l, "mc_l", change_l);
}
// color fade function
fade_color = function(red_dest, green_dest, blue_dest, mc_name, change_from) {
var mycolor = new Color(mc_name);
onEnterFrame = function(){
//first check if each color destination value is higher or lower than the initial set value - increase or decrease colors_from until destination is reached
//change red
if (red_dest>=change_from.rb) {
if (change_from.rb<red_dest) {
change_from.rb += 3;
}
} else {
if (change_from.rb>red_dest) {
change_from.rb -= 3;
}
}
//change green
if (green_dest>=change_from.gb) {
if (change_from.gb<green_dest) {
change_from.gb += 3;
}
} else {
if (change_from.gb>green_dest) {
change_from.gb -= 3;
}
}
//change blue
if (blue_dest>=change_from.bb) {
if (change_from.bb<blue_dest) {
change_from.bb += 3;
}
} else {
if (change_from.bb>blue_dest) {
change_from.bb -= 3;
}
}
mycolor.setTransform(change_from);
}
}