PDA

View Full Version : What is wrong with this function..?



antialan81
March 17th, 2005, 04:33 AM
Hello, may i know what is wrong with this function? This is a function which I use to trigger an action with different time duration. When I call this function it just wont work.

function shoot1(){
x=random(2)+1;
trace(x);
if(x==1){
timera1= setInterval (shoota1,1000);
function shoota1() {
clearInterval(timera1);
_root.spider1.gotoAndPlay(2);
}
}
else if(x==2){
timera2= setInterval (shoota2,2000);
function shoota2() {
clearInterval(timera2);
_root.spider1.gotoAndPlay(2);
}
}
}

Dutchy
March 17th, 2005, 04:49 AM
It works like this:


function shoot1() {
x = random(2)+1;
trace(x);
if (x == 1) {
timera1 = setInterval(shoota1, 1000);
} else if (x == 2) {
timera2 = setInterval(shoota2, 2000);
}
}
function shoota2() {
trace("shoota2");
clearInterval(timera2);
_root.spider1.gotoAndPlay(2);
}
function shoota1() {
trace("shoota1");
clearInterval(timera1);
_root.spider1.gotoAndPlay(2);
}
shoot1();

hope it helped.
Dutchy

antialan81
March 17th, 2005, 05:04 AM
ya, it really help a lot~ :D thanks ya. Now the function can function already