Dynamically Changing States | 315
private function fireBeam (evt:Event)
{
beam.play ( );
aFlag=0;
aeFlag=0;
}
//Android beam hits Alien or Earthling
private function beamHit (evt:Event)
{
if (beam.hitTestObject(alienMC) && aFlag==0)
{
aFlag=1;
aKiller++;
scoreSetter.setScore (aKiller,"BeamHit on Alien");
dataOut ( );
if (aKiller >= 5)
{
scoreSetter.setScore (aKiller,"Alien Out");
alien.nomDeGuerre="Alien Destroyed";
this.alienMC.rotation=90;
torpedo.rotation=90;
killWarrior (alien);
dataOut ( );
}
}
if (beam.hitTestObject(earthlingMC) && aeFlag==0)
{
aeFlag=1;
eKiller++;
scoreSetter.setScore (eKiller,"BeamHit on Earthling");
dataOut ( );
if (eKiller >= 5)
{
scoreSetter.setScore (eKiller,"Earthling Out");
earthling.nomDeGuerre="Earthling Off";
this.earthlingMC.rotation=90;
missile.rotation=90;
killWarrior (earthling);
dataOut ( );
}
}
}
//Alien Fires torpedo
private function fireTorpedo (evt:Event)
{
torpedo.play ( );
lFlag=0;
}
//Alien hits Earthling
private function alienHit (evt:Event)
{
this.earthlingMC=earthlingMC;
Example 8-19. ChangeHandler.as (continued)