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();
} }