# Minimal Actionscript help!

**URL:** https://forum.kirupa.com/t/minimal-actionscript-help/174894
**Category:** Uncategorized
**Created:** [January 10, 2006, 3:58am UTC](https://forum.kirupa.com/t/minimal-actionscript-help/174894 "2006-01-10T03:58:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Soig](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Soig](https://forum.kirupa.com/u/Soig)
#### Post date: [January 10, 2006, 3:58am UTC](https://forum.kirupa.com/t/minimal-actionscript-help/174894/1 "2006-01-10T03:58:56Z")

</div>

I have this line of code that I’m using for a smart button that changes dynamically. But I have roughly 20 buttons and I don’t think it is efficient to retype this code. The only two variables that will change are marked in red. (q1: everywhere it applies and answer). Can I create a function taht will call this greater code and pass it those two variables?

Oh, I forgot to mention that q1 will incriment numerically (q2, q3, etc…). That may make the code a bit more dynamic. Any thoughts?

Thanks everyone!

> \_root.[COLOR=Red]q1[/COLOR].onRollOver = function() {  
> if(\_root.currentlyLoaded != “[COLOR=Red]q1[/COLOR]”){  
> \_root.[COLOR=Red]q1[/COLOR].gotoAndStop(“over”); } }  
> \_root.[COLOR=Red]q1[/COLOR].onRollOut = function() {  
> if(\_root.currentlyLoaded != “[COLOR=Red]q1[/COLOR]”){  
> \_root.[COLOR=Red]q1[/COLOR].gotoAndPlay(“up”); } }  
> \_root.[COLOR=Red]q1[/COLOR].onRelease = function() {  
> \_root.[COLOR=Red]q1[/COLOR].gotoAndStop(“down”);  
> if(\_root.currentlyLoaded != “[COLOR=Red]q1[/COLOR]”){  
> \_root.currentlyLoaded = “[COLOR=Red]q1[/COLOR]”;  
> [COLOR=Red] \_root.answer = “The answer will go here”;[/COLOR]  
> \_root.clearAll();  
> } }
