Help with - Creating a Enemies killed counter
Ok here is what ive been trying to do. Everytime a monster dies, I want the monsters killed dynamic text field to increase the number by 1. I gave it a good shot but it feels like im missing something basic, Im fairly new to this still but picking it up quickly. The following code is inside of a movieClip dealing with the monsters. The second block of code is on my main timeline.
Quote:
import fl.motion.Animator;
import fl.motion.MotionEvent
var this_xml:XML = <Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>
<Source frameRate="30" x="240.4" y="201.35" scaleX="0.39" scaleY="0.39" rotation="0" elementType="movie clip" symbolName="mcMonster">
<dimensions>
<geom:Rectangle left="0" top="0" width="109.2" height="125.4"/>
</dimensions>
<transformationPoint>
<geom:Point x="0.5" y="0.5"/>
</transformationPoint>
</Source>
</source>
<Keyframe index="0" tweenSnap="true" tweenSync="true">
<tweens>
<SimpleEase ease="0"/>
</tweens>
</Keyframe>
<Keyframe index="29" scaleX="2.564102564102564" scaleY="2.564102564102564"/>
</Motion>;
var this_animator:Animator = new Animator(this_xml, this);
this_animator.play();
this_animator.addEventListener(MotionEvent.MOTION_ END, hurtPlayer);
function hurtPlayer(event:MotionEvent):void
{
this.parent.removeChild(this);
}
this.addEventListener(MouseEvent.CLICK, killMonster);
function killMonster (event:MouseEvent):void
{
this_xml = <Motion duration="5" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>
<Source frameRate="30" x="217.2" y="143.8" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" symbolName="Monster" class="Monster">
<dimensions>
<geom:Rectangle left="-55" top="-64" width="109.2" height="125.4"/>
</dimensions>
<transformationPoint>
<geom:Point x="0.5004578754578755" y="0.5003987240829346"/>
</transformationPoint>
</Source>
</source>
<Keyframe index="0" rotateDirection="cw" rotateTimes="1" tweenSnap="true" tweenSync="true">
<tweens>
<SimpleEase ease="0.2"/>
</tweens>
</Keyframe>
<Keyframe index="4" scaleX="0.574" scaleY="0.574">
<color>
<Color alphaMultiplier="0.08"/>
</color>
</Keyframe>
</Motion>;
this_animator = new Animator(this_xml, this);
this_animator.play();
this_animator.addEventListener(MotionEvent.MOTION_ END, die);
}
function die (event:MotionEvent):void
{
this_animator.removeEventListener(MotionEvent.MOTI ON_END, hurtPlayer)
this.parent.removeChild(this);
}
Quote:
var monstersInGame:uint;
var monsterMaker:Timer;
var container_mc:MovieClip;
var cursor:MovieClip;
function initializeGame():void
{
monstersInGame = 10;
monsterMaker = new Timer(1000, monstersInGame);
container_mc = new MovieClip();
addChild(container_mc);
monsterMaker.addEventListener(TimerEvent.TIMER, createMonsters);
monsterMaker.start();
cursor = new Cursor();
addChild(cursor);
cursor.enabled = false;
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
}
function dragCursor(event:MouseEvent):void
{
cursor.x = this.mouseX
cursor.y = this.mouseY
}
function createMonsters(event:TimerEvent):void
{
var monster:MovieClip;
monster = new Monster();
monster.x = Math.random() * stage.stageWidth;
monster.y = Math.random() * stage.stageHeight;
container_mc.addChild(monster);
}
initializeGame();
THanks for the help.