leahgrace
May 20th, 2005, 04:25 PM
I'm trying to create a custom function called "turnOn" with (name) as the function variable(?is that how I should refer to it?). This function is an if/else statement that will be called through an on(release) button event.
The if has a bunch of && conditions, if true gotoAndStop on frame two of specified movie clip. But I'm trying to write it put it in a function so that I don't have to put all this code on every single button. So i'm using the "name" function variable to specify the movieclip that should be affected by button action, but it won't work. Is it possible to do this? What I have now is like this:
function turnOn (name) {
if (polPlan_mc._currentframe == 1 && baseDB_mc._currentframe == 1 && polNum_mc._currentframe == 1 && paidTo_mc._currentframe == 1 && addBen_mc._currentframe == 1 && dividend_mc._currentframe == 1 && insured_mc._currentframe == 1 && lifeDB_mc._currentframe == 1 && netCV_mc._currentframe == 1 && polCV_mc._currentframe == 1 && polDate_mc._currentframe == 1 && premium_mc._currentframe == 1 && summary_mc._currentframe == 1 && totalDB_mc._currentframe == 1) {
name+.gotoAndStop(2);
} else {
polPlan_mc.gotoAndStop(1);
polNum_mc.gotoAndStop(1);
baseDB_mc.gotoAndStop(1);
paidTo_mc.gotoAndStop(1);
addBen_mc.gotoAndStop(1);
dividend_mc.gotoAndStop(1);
insured_mc.gotoAndStop(1);
lifeDB_mc.gotoAndStop(1);
netCV_mc.gotoAndStop(1);
polCV_mc.gotoAndStop(1);
polDate_mc.gotoAndStop(1);
premium_mc.gotoAndStop(1);
summary_mc.gotoAndStop(1);
totalDB_mc.gotoAndStop(1);
name+.gotoAndStop(2);
}
}
and then on the button instance I have
on (release) {
_root.turnOn ("insured_mc")
obviously something is wrong because it's not working, and I'm guessing it has to do with the fact that .gotoAndStop(2); isn't a string and I can't just add "insured_mc" to it, but is there a way for me to do this so that I don't have to put this function code on every single button?
The if has a bunch of && conditions, if true gotoAndStop on frame two of specified movie clip. But I'm trying to write it put it in a function so that I don't have to put all this code on every single button. So i'm using the "name" function variable to specify the movieclip that should be affected by button action, but it won't work. Is it possible to do this? What I have now is like this:
function turnOn (name) {
if (polPlan_mc._currentframe == 1 && baseDB_mc._currentframe == 1 && polNum_mc._currentframe == 1 && paidTo_mc._currentframe == 1 && addBen_mc._currentframe == 1 && dividend_mc._currentframe == 1 && insured_mc._currentframe == 1 && lifeDB_mc._currentframe == 1 && netCV_mc._currentframe == 1 && polCV_mc._currentframe == 1 && polDate_mc._currentframe == 1 && premium_mc._currentframe == 1 && summary_mc._currentframe == 1 && totalDB_mc._currentframe == 1) {
name+.gotoAndStop(2);
} else {
polPlan_mc.gotoAndStop(1);
polNum_mc.gotoAndStop(1);
baseDB_mc.gotoAndStop(1);
paidTo_mc.gotoAndStop(1);
addBen_mc.gotoAndStop(1);
dividend_mc.gotoAndStop(1);
insured_mc.gotoAndStop(1);
lifeDB_mc.gotoAndStop(1);
netCV_mc.gotoAndStop(1);
polCV_mc.gotoAndStop(1);
polDate_mc.gotoAndStop(1);
premium_mc.gotoAndStop(1);
summary_mc.gotoAndStop(1);
totalDB_mc.gotoAndStop(1);
name+.gotoAndStop(2);
}
}
and then on the button instance I have
on (release) {
_root.turnOn ("insured_mc")
obviously something is wrong because it's not working, and I'm guessing it has to do with the fact that .gotoAndStop(2); isn't a string and I can't just add "insured_mc" to it, but is there a way for me to do this so that I don't have to put this function code on every single button?