# More help with code for transforming scale and color

**URL:** https://forum.kirupa.com/t/more-help-with-code-for-transforming-scale-and-color/176217
**Category:** Uncategorized
**Created:** [January 21, 2006, 7:43pm UTC](https://forum.kirupa.com/t/more-help-with-code-for-transforming-scale-and-color/176217 "2006-01-21T19:43:46Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ohbeewan](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ohbeewan/32/1745_2.png) [@ohbeewan](https://forum.kirupa.com/u/ohbeewan)
#### Post date: [January 21, 2006, 7:43pm UTC](https://forum.kirupa.com/t/more-help-with-code-for-transforming-scale-and-color/176217/1 "2006-01-21T19:43:46Z")

</div>

Here is some code I’m trying to finish. It does two things: Fades the color of a movieclip to another color, and scales (increases the width) the rectangular movie clip - all of this I figured out with the help of some very nice folks on this forum, so thanks!

The code works, the mc resizes and fades to the desired color, BUT I need the movieclip to scale back (decrease in width) once it reaches it’s target width of 400.

I’ve tried a few things, but uh, not quite finding it…any ideas? Thanks again! Here’s the code:

// mc\_retangle contains a black retangle…  
var mycolor = new Color(mc\_retangle);  
var change = {rb:169,gb:195,bb:217};  
mycolor.setTransform(change);

button.onRelease = function() {  
// scale movieclip  
mc\_retangle.onEnterFrame = function(){  
if ( mc\_retangle.\_width\<=400) {  
mc\_retangle.\_width += 40;  
} else {  
delete this.onEnterFrame;  
}  
}

// fade color  
//varibles to mix desired color  
var red\_dest = 219;  
var green\_dest = 201;  
var blue\_dest = 174;

onEnterFrame = function(){  
//change red//  
if (red\_dest\>=change.rb) {  
if (change.rb\<red\_dest) {  
change.rb += 3;  
}  
} else {  
if (change.rb\>red\_dest) {  
change.rb -= 3;  
}  
}  
//change green//  
if (green\_dest\>=change.gb) {  
if (change.gb\<green\_dest) {  
change.gb += 3;  
}  
} else {  
if (change.gb\>green\_dest) {  
change.gb -= 3;  
}  
}  
//change blue//  
if (blue\_dest\>=change.bb) {  
if (change.bb\<blue\_dest) {  
change.bb += 3;  
}  
} else {  
if (change.bb\>blue\_dest) {  
change.bb -= 3;  
}  
}  
mycolor.setTransform(change);  
}

}
