The event is not Firing!!! Why? The “hitplayer” is supposes to fire and thats the one I’m having the problem with. It wont even trace. I know its a problem with the event because it works fine with Event.ENTER_FRAME.
the listener:
public function FightingGame() {
addEventListener(Event.ADDED_TO_STAGE, FightingGameBuild, false, 0, true);
}
public function FightingGameBuild(event:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, FightingGameBuild);
buildLevel();
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownlistener);
stage.addEventListener(KeyboardEvent.KEY_UP,keyuplistener);
addEventListener(HittingEvent.HITPLAYER,playerHit);
gametimer = new Timer(25);
gametimer.addEventListener(TimerEvent.TIMER,Update);
gametimer.start();
}
the custom event:
package
{
import flash.events.Event;
public class HittingEvent extends Event
{
public static const HITPLAYER:String = "hitplayer";
public static const HITENEMY:String = "hitenemy";
public function HittingEvent( type:String )
{
super (type);
}
}
}
the function:
public function playerHit(hittingevent:HittingEvent):void
{
trace("hit");
if (fighter.hitTestObject(enemy))
{
if (PixelPerfectCollisionDetection.isColliding(fighter,enemy,this,true))
{
canMove = false;
isJumping = false;
isAttacking = false;
i**** = true;
removeChild(enemy);
dy = fighter.y - enemy.y;
dx = fighter.x - enemy.x;
Radians = Math.atan2(dy,dx);
}
}
}
the dispatch code is on the first frame of a child movieclip:
dispatchEvent(new HittingEvent(HittingEvent.HITPLAYER));