PDA

View Full Version : Button Action script


tOyShOp
07-23-2004, 02:59 PM
I have 5 buttons, and 5 movies.

I want each of the button on rollover to play its corresponding movie.

i.e. butn1 to play mov1, butn 2 to play mov2...

I tried to do it with this action script. But it doesn't work. Please help.


for (n = 0; n < 6; n++) {

eval("butn"+n).onRollOver = function () {

_root.eval("tri"+n)._visible=true;

}
eval("butn"+n).onRollOut = function () {

_root.eval("tri"+n)._visible=false;

}

}

Somehow, it seems that eval("tri"+n) is not recognized. because if i replaced it with an exact "tri1" or "tri2", the code works.

Thank you.

tg
07-23-2004, 03:41 PM
try:

for (n = 0; n < 6; n++) {
this["butn"+n].onRollOver = function () {
_root["tri"+n]._visible=true;
}
this["butn"+n].onRollOut = function () {
_root["tri"+n]._visible=false;
}
}