Hi … I am fairly new to Flash AS. I have this problem I am unable to wrap my head around. I am writing a small game, and basically I would like events happening in say frame1 to go to frame2 to execute, but it seems code only run once on frame2 and then when gotoAndStop at again, it does not execute.
Here’s the code to illustrate my point:
frame1:
_global.testnum = 0;
timerInterval = setInterval(this, “processInterval”, 1000);
function processInterval()
{
_global.testnum++;
if (_global.testnum % 2 == 0)
{
trace("f1 " + _global.testnum);
_root.gotoAndStop(“frame2”);
}
}
stop();
frame2
trace("f2 " + _global.testnum);
stop();
Actual output
f1 2
f2 2
f1 4
f1 6
f1 8
…
I was expecting this output instead:
f1 2
f2 2
f1 4
f2 4
f1 6
f2 6
…
But I never did get this. I’ve tried various methods and it doesn’t work. For the purpose of my game design, I need the events triggered in frame 1 to be executed in frame 2 (which is designed to do a bunch of stuff like update the interface, etc etc), so I wouldn’t want to put those code into the processInterval() function in frame 1 above.
I’ll really appreciate any help / enlightenment on this problem …
Thanks a million in advance for any insights!