I am making a little game in as3.
The game contains 10 levels.
When I enter level 1, everything is in order. But when I enter the second level (frame), the event listeners from the first frame still work and get a warning saying "Unable to access the object with a null reference to the object." This is because I delete every first level object and add objects from stage 2.
I tried to use removeEventListeners, but this will not work because the ENTER_FRAME listeners work again after removing the Listen Listers.
I tried using different frames for different levels, the bit is not working. I also tried using 1 frmae for all 10 frames, but I get a lot of warnings, and Flash Loader is overloaded.
How can I switch levels (back and forth)? Thanks in advance.
addEventListener(Event.ENTER_FRAME, subtracting2);
arrListeners.pop();
function subtracting2 (e:Event):void
{
count--;
var FAcoef:Number = count/30;
FadeAway.alpha = FAcoef;
setChildIndex(FadeAway, numChildren - 1);
if(count == 0)
{
setChildIndex(FadeAway, 0);
removeEventListener(Event.ENTER_FRAME, subtracting2);
}
}
source
share