PDA

View Full Version : make it short


toke
09-23-2002, 07:44 PM
ok.. i guess i'm stupid here. is there anyway i can make this script shorter

if (puk == "box1"){
_root.tempo = _root.texts[0]
} else if (puk == "box2") {
_root.tempo = _root.texts[1]
} else if (puk == "box3") {
_root.tempo = _root.texts[2]
.
.
.

using what kind of loop? thanks.

tg
09-23-2002, 10:16 PM
try:

_root.tempo=_root.texts[(puk.slice(3,puk.length)-1)];

toke
09-24-2002, 07:21 PM
Thank you tg. I'll try that.

toke
09-24-2002, 07:38 PM
It works! Thank you thank you. could you please take a moment to explain how the code work? I know that using slice() will extract array. me little knowledge

toke
09-24-2002, 08:23 PM
ok ok. i see what the code does. thanks again. :D

tg
09-24-2002, 10:28 PM
glad to here it.

hah! i like your dancing pig.