hello i need some help converting the as2 into as3
here is the code:
var bulletOffset:Number = 10; //pixels - bigger number = less acurate
var bulletLifeTimerTotal:Number = 20; //fps
var bulletSpeed:Number = 10; //pixels
var reloadSpeed:Number = 200; //ms 1000 = 1 second
//Declare variables that we're going to be reusing
//(this saves them in memory thus speeding everything up a little)
var reloadTimer:Number;
var reloadComplete:Boolean = true;
var bulletAngle:Number;
var randomNum:Number;
var playerX:Number;
var playerY:Number;
var rotationDirection:Number;
/**
*
* Fire Weapon
*
*/
function fireWeapon():Void
{
//check if weapon is reloaded, if true, fire bullet
if(reloadComplete == true)
{
//attach bullet
var bullet_mc:MovieClip = _root.attachMovie("bullet", "b"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
//position bullet on player
bullet_mc._x = player_mc._x;
bullet_mc._y = player_mc._y;
bullet_mc.bulletLifeTimer = 0;
//calculate random bullet offset.
randomNum = random(bulletOffset)-(bulletOffset/2);
//set bullet firing angle
bulletAngle = ((player_mc._rotation+randomNum-90)*Math.PI/180);
bullet_mc.xSpeed = Math.cos(bulletAngle)*bulletSpeed;
bullet_mc.ySpeed = Math.sin(bulletAngle)*bulletSpeed;
//make it move
bullet_mc.onEnterFrame = function() {
//move bullet
this._x += this.xSpeed;
this._y += this.ySpeed;
//
//check if bullet needs to die of old age
if (this.bulletLifeTimer>=bulletLifeTimerTotal) {
this.removeMovieClip();
}
//update bullet timer
this.bulletLifeTimer++;
};
//start reloading gun
startReloading();
}
}
//start reloading weapon
function startReloading()
{
reloadComplete = false;
//set a timer that will call the gunReloaded function after "reloadSpeed" time passes
reloadTimer = setInterval(this, "gunReloaded", reloadSpeed);
}
//gun reloaded function - clears timers and sets reloaded to true
function gunReloaded()
{
clearInterval(reloadTimer);
reloadComplete = true;
}