# How To Condensing this Code? Button related

**URL:** <https://forum.kirupa.com/t/how-to-condensing-this-code-button-related/216335>\
**Category:** Uncategorized\
**Created:** [February 15, 2007, 4:19pm UTC](https://forum.kirupa.com/t/how-to-condensing-this-code-button-related/216335 "2007-02-15T16:19:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RoyalAssassin](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@RoyalAssassin](https://forum.kirupa.com/u/RoyalAssassin)\
**Post date:** [February 15, 2007, 4:19pm UTC](https://forum.kirupa.com/t/how-to-condensing-this-code-button-related/216335/1 "2007-02-15T16:19:50Z")

</div>

Here’s the code that handles my button functions:

nav\_hc.onRollOver = function() {  
\_root.rollWws();  
};

nav\_hc.onRollOut = function(){  
\_root.rollOutWws();  
\_root.button02.active = true;  
}

nav\_hc.onPress = function(){  
\_root.releaseWws(“gallery”);  
\_root.loader.loadClip(\_root.newSec, \_root.m\_blank);  
\_root.xmlSection = 1;  
};

I need to duplicate that code for about 10 different buttons, with the only thing changing being the xmlSection variable. Is there a way to condense this code without simply duplicating it 10 times? A loop of some sort? Thanks
