_StOrM_
%Europe/Berlin %814 %2008, 20:32
Ik heb volgende functie :
function TabHandler() {
if (Key.isDown(Key.TAB)) {
tot1_txt.text = Number(aant1_txt.text*stkpr1_txt.text);
afrond(Number(tot1_txt.text),2);
tot2_txt.text = Number(aant2_txt.text*stkpr2_txt.text);
afrond(Number(tot2_txt.text),2);
tot3_txt.text = Number(aant3_txt.text*stkpr3_txt.text);
afrond(Number(tot3_txt.text),2);
tot4_txt.text = Number(aant4_txt.text*stkpr4_txt.text);
afrond(Number(tot4_txt.text),2);
tot5_txt.text = Number(aant5_txt.text*stkpr5_txt.text);
afrond(Number(tot5_txt.text),2);
tot6_txt.text = Number(aant6_txt.text*stkpr6_txt.text);
afrond(Number(tot6_txt.text),2);
tot7_txt.text = Number(aant7_txt.text*stkpr7_txt.text);
afrond(Number(tot7_txt.text),2);
tot8_txt.text = Number(aant8_txt.text*stkpr8_txt.text);
afrond(Number(tot8_txt.text),2);
tot9_txt.text = Number(aant9_txt.text*stkpr9_txt.text);
afrond(Number(tot9_txt.text),2);
tot10_txt.text = Number(aant10_txt.text*stkpr10_txt.text);
afrond(Number(tot10_txt.text),2);
tot11_txt.text = Number(aant11_txt.text*stkpr11_txt.text);
afrond(Number(tot11_txt.text),2);
tot12_txt.text = Number(aant12_txt.text*stkpr12_txt.text);
afrond(Number(tot12_txt.text),2);
tot13_txt.text = Number(aant13_txt.text*stkpr13_txt.text);
afrond(Number(tot13_txt.text),2);
checkEmpty(tot1_txt);
checkEmpty(tot2_txt);
checkEmpty(tot3_txt);
checkEmpty(tot4_txt);
checkEmpty(tot5_txt);
checkEmpty(tot6_txt);
checkEmpty(tot7_txt);
checkEmpty(tot8_txt);
checkEmpty(tot9_txt);
checkEmpty(tot10_txt);
checkEmpty(tot11_txt);
checkEmpty(tot12_txt);
checkEmpty(tot13_txt);
//calculateMVH();
//checkEmpty(mvh_txt);
}
}
en wou deze vervangen door een for loopje:
function TabHandler(){
if (Key.isDown(Key.TAB)) {
for (var i = 1; i >= aantalRegels; i++) {
var tempTot = _root["tot"+i+"_txt"];
var tempAantal = _root["aant"+i+"_txt"];
var tempStkpr= _root["stkpr"+i+"_txt"];
tempTot.text = Number(tempAantal.text*tempStkpr.text);
afrond(Number(tempTot.text),2);
}
}
}
dit omdat dat heel wat regels code bespaart en zo kan ik ook tot zoveel gaan als ik wil met nummering van tekstveldje, maar het werkt niet echt meer ... Enig idee?
function TabHandler() {
if (Key.isDown(Key.TAB)) {
tot1_txt.text = Number(aant1_txt.text*stkpr1_txt.text);
afrond(Number(tot1_txt.text),2);
tot2_txt.text = Number(aant2_txt.text*stkpr2_txt.text);
afrond(Number(tot2_txt.text),2);
tot3_txt.text = Number(aant3_txt.text*stkpr3_txt.text);
afrond(Number(tot3_txt.text),2);
tot4_txt.text = Number(aant4_txt.text*stkpr4_txt.text);
afrond(Number(tot4_txt.text),2);
tot5_txt.text = Number(aant5_txt.text*stkpr5_txt.text);
afrond(Number(tot5_txt.text),2);
tot6_txt.text = Number(aant6_txt.text*stkpr6_txt.text);
afrond(Number(tot6_txt.text),2);
tot7_txt.text = Number(aant7_txt.text*stkpr7_txt.text);
afrond(Number(tot7_txt.text),2);
tot8_txt.text = Number(aant8_txt.text*stkpr8_txt.text);
afrond(Number(tot8_txt.text),2);
tot9_txt.text = Number(aant9_txt.text*stkpr9_txt.text);
afrond(Number(tot9_txt.text),2);
tot10_txt.text = Number(aant10_txt.text*stkpr10_txt.text);
afrond(Number(tot10_txt.text),2);
tot11_txt.text = Number(aant11_txt.text*stkpr11_txt.text);
afrond(Number(tot11_txt.text),2);
tot12_txt.text = Number(aant12_txt.text*stkpr12_txt.text);
afrond(Number(tot12_txt.text),2);
tot13_txt.text = Number(aant13_txt.text*stkpr13_txt.text);
afrond(Number(tot13_txt.text),2);
checkEmpty(tot1_txt);
checkEmpty(tot2_txt);
checkEmpty(tot3_txt);
checkEmpty(tot4_txt);
checkEmpty(tot5_txt);
checkEmpty(tot6_txt);
checkEmpty(tot7_txt);
checkEmpty(tot8_txt);
checkEmpty(tot9_txt);
checkEmpty(tot10_txt);
checkEmpty(tot11_txt);
checkEmpty(tot12_txt);
checkEmpty(tot13_txt);
//calculateMVH();
//checkEmpty(mvh_txt);
}
}
en wou deze vervangen door een for loopje:
function TabHandler(){
if (Key.isDown(Key.TAB)) {
for (var i = 1; i >= aantalRegels; i++) {
var tempTot = _root["tot"+i+"_txt"];
var tempAantal = _root["aant"+i+"_txt"];
var tempStkpr= _root["stkpr"+i+"_txt"];
tempTot.text = Number(tempAantal.text*tempStkpr.text);
afrond(Number(tempTot.text),2);
}
}
}
dit omdat dat heel wat regels code bespaart en zo kan ik ook tot zoveel gaan als ik wil met nummering van tekstveldje, maar het werkt niet echt meer ... Enig idee?