I'm really confused here. I get the code to work flawlessly and then went back and tried something and now it won't work. I can't seem to figure out when now and I'm starting to be really frustrated as a result. I also don't seem to get any errors handed to me.
I got two files Gameindex and one that is an external swf which is my level imported on top of the gameindex. I want to move to somewhere else on the timeline when the event is called but as of now calling the event isn't working.
My code in the level is as such:
private function enterFrameHandler(event:Event):void
{
updatePosition();
updateRotation();
scorebox.text=String(score);
var t:Number = Math.random();
if(t>0.98) {
addasteroid();
}
for (var a:int = 0;a<allast.length;a++) {
if (contains(allast[a])) {
for (var b:int = 0;b<allbullets.length;b++) {
if (allbullets[b].hitTestObject(allast[a])) {
//removeChild(allbullet[b]);
if (contains(allast[a])) {
removeChild(allast[a]);
}
//score
score+=5;
if (score==20) {
dispatchEvent(new Event("next_level"));
}
}
if (allast[a].hitTestObject(_player)) {
//removeChild(allbullet[b]);
trace("hitplayer");
endGame();
}
}
allast[a].y += 2;
}
}
}//function
Now in my game index I have the fallowing code:
import flash.events.Event;
addEventListener("next_level", movetointro);
function movetointro(e:Event){
trace("IT IS WORKING");}
Why don't me movetointro function work?