PDA

Volledige versie bekijken : functie werkt na 1x niet meer goed


clan-kill3r
%Europe/Berlin %585 %2007, 14:03
i = 1;
z = 2;
function timer() {
trace("timer"+i);
this.onEnterFrame = function() {
i++;
trace("i is"+i);
if (i == 24) {
volgende();
}
};
}
//
attachMovie("b1h_p1", "p1", 1);
attachMovie("b1h_p2", "p2", 2);
p2._x = -550;
//
function volgende() {
z++;
this.onEnterFrame = function() {
p1._x += 27.5;
p2._x += 27.5;
if (p1._x == 550) {
p1._name = "p_temp";
p2._name = "p1";
p_temp._name = "p2";
p1.swapDepths(p2);
attachMovie("b1h_p"+z, "p2", 2);
p2._x = -550;
trace("i voor"+i);
i = 1;
timer();
trace("i na"+i);
delete this.onEnterFrame;
}
};
}
//
//volgende();
timer();


De eerste x werkt de timer wel, de 2e keer komt hij bij de eerste trace maar doet hij het on enterframe effent niet meer. Hoe kan dat of hoe los ik dit op?


dit is de trace:

timer1
i is2
i is3
i is4
i is5
i is6
i is7
i is8
i is9
i is10
i is11
i is12
i is13
i is14
i is15
i is16
i is17
i is18
i is19
i is20
i is21
i is22
i is23
i is24
i voor24
timer1
i na1

PeaceFrog
%Europe/Berlin %633 %2007, 15:12
Ik denk omdat je de onEnterFrame delete?


peace

clan-kill3r
%Europe/Berlin %648 %2007, 15:33
dacht ik ook al aan, ik heb nu dit als totale code en dat werkt:

i = 1;
z = 2;
//
attachMovie("b1h_p1", "p1", 1);
attachMovie("b1h_p2", "p2", 2);
p2._x = -550;
//
this.onEnterFrame = function() {
i++;
trace (i);
if (i > 23) {
p1._x += 22;
p2._x += 22;
if (p1._x == 550) {
p1._name = "p_temp";
p2._name = "p1";
p_temp._name = "p2";
p1.swapDepths(p2);
z++;
attachMovie("b1h_p"+z, "p2", 2);
p2._x = -550;
i = 1;
}
}
};

xtr0
%Europe/Berlin %653 %2007, 15:40
edit: oeps het lukt al zo te zien :P