Hello all,
I'm having a problem in a game where I try to press spacebar to make a player throw grenades. It works ok until I try to throw another grenade before the 1st grenade goes off. When I do that only the second grenade goes off and the first grenade is a dudd. I'm using getTimer() to get the time the grenade is thrown, then , well anyway heres the code. If someone has experience with this and could tell me how to fix it I would be forever in their debt.




public function throwIt(_docClass:LunarMayhem, origClassName:Object, playerX:Number, playerY:Number, dir:String) {

this._docClass = _docClass;

_spriteGridClass3.initTileSheetData();
grenade.image = new BlitSprite(_tileSheet3, _spriteGridClass3.grenadeFrames, 0);

if(dir == "right"){
xPos = playerX + 80;
}else{
xPos = playerX + 15;
}
yPos = playerY - 60;

grenade.gravity = 0;
grenade.gravityLimit = 25;
grenade.throwSpeed= 15;
grenade.throwSpeedLimit = 25;
grenade.verticalChange=0;
grenade.horizontalChange=0;

grenade.dx = 0;
grenade.dy = 0;
grenade.dir = dir;
grenade.scaleX = .75;
grenade.scaleY = .75;
grenade.currentTile = 0;
grenade.image.x = xPos;
grenade.image.y = yPos;
grenade.image.renderCurrentTile(true);
grenade.visible = true;
grenade.releaseTime = getTimer();
grenade.timePassed;

_docClass.gameLevelFG.addChild(grenade.image);
_gameModel.grenadesThrown.push(grenade);

}



public function update(_docClass:LunarMayhem):void{



for(var i:int = _gameModel.grenadesThrown.length-1; i >= 0; i--)
{

_gameModel.grenadesThrown[i].timePassed = getTimer()
- _gameModel.grenadesThrown[i].releaseTime;

trace(_gameModel.grenadesThrown[i].timePassed);

if(_gameModel.grenadesThrown[i].timePassed > 3000){
blowUp(_gameModel.grenadesThrown[i],_docClass);
}
if(_gameModel.grenadesThrown[i].timePassed > 5000){
dispose(_gameModel.grenadesThrown[i]);
}
updateExplode(_gameModel.grenadesThrown[i]);


...... function continues but the problem is above. When I look at what the trace statement produces it shows that the timer starts over for both grenades when the second grenade is thrown, instead of the 2 grenades having different time, you digg? So if someone could help that would be that would be great. Thanks