PDA

View Full Version : if and if and if - must be an easier way??



iflashtrated
June 30th, 2006, 10:44 AM
Could anyone offer advise as to a more efficient way of writing the following please:

function trailReveal() {
if (_root.mover.hitTest(_root.dot1)) {
_root.dot1._visible = true;
//trace("trail left3");
}
if (_root.mover.hitTest(_root.dot2)) {
_root.dot2._visible = true;

}
if (_root.mover.hitTest(_root.dot3)) {
_root.dot3._visible = true;

}
if (_root.mover.hitTest(_root.dot4)) {
_root.dot4._visible = true;

}
}

kookaburra
June 30th, 2006, 10:56 AM
function trailReveal() {
for(var i=1;i<=4;i++){}
if (_root.mover.hitTest(_root["dot"+i])) {
_root["dot"+i]._visible = true;
//trace("trail left "+i);
}}
}

iflashtrated
June 30th, 2006, 11:18 AM
Thanks for that :pleased: It really helps when you have 90 mc to deal with