# Help to optimize my code

**URL:** https://forum.kirupa.com/t/help-to-optimize-my-code/158715
**Category:** Uncategorized
**Created:** [August 11, 2005, 12:17pm UTC](https://forum.kirupa.com/t/help-to-optimize-my-code/158715 "2005-08-11T12:17:44Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![5TEF](https://avatars.discourse-cdn.com/v4/letter/5/85e7bf/32.png) [@5TEF](https://forum.kirupa.com/u/5TEF)
#### Post date: [August 11, 2005, 12:17pm UTC](https://forum.kirupa.com/t/help-to-optimize-my-code/158715/1 "2005-08-11T12:17:44Z")

</div>

Hi,  
i’ve got 7 MC ( as buttons )  
i’ve got this code on the first MC :

[color=Sienna]for (r=1; r\<=7; r++) {  
this.[color=Green]pur1[/color].onRollOver = function() {  
this.\_parent.[color=SeaGreen]txt1[/color].slide(110, 0.2);  
if (r\<\>[color=SeaGreen]1[/color]) {  
this.\_parent[“txt”+r].slide(600, 0.2);  
}  
};  
}

[color=Black]it works great.  
but i want the same code for other 6 buttons.  
the only things to change is in green ( pur2,pur3,etc… )

i don’t to make 7 times the same code, so i think i can optimize it !

i try to use array, but don’t found the fast and good solution.

can you help me ?

[/color][/color]
