Actionscript 3 如何删除重复的变量定义,而不妨碍我的游戏?

Actionscript 3 如何删除重复的变量定义,而不妨碍我的游戏?,actionscript-3,flash,Actionscript 3,Flash,我正在尝试制作一个游戏,但flash给了我以下警告代码: 场景1,“roachLevel”层,第1帧,第98行警告:3596:重复变量定义 每次我删除“复制变量”都会妨碍我的游戏,游戏将无法正常运行。 这是发生警告的代码: function moveEnemies():void { var tempEnemy:MovieClip; for (var i:int =enemies.length-1; i>=0; i--) { var tempEnemy=enemies[i];

我正在尝试制作一个游戏,但flash给了我以下警告代码:

场景1,“roachLevel”层,第1帧,第98行警告:3596:重复变量定义

每次我删除“复制变量”都会妨碍我的游戏,游戏将无法正常运行。 这是发生警告的代码:

function moveEnemies():void
{
var tempEnemy:MovieClip;


for (var i:int =enemies.length-1; i>=0; i--)
{
     var tempEnemy=enemies[i];
if (tempEnemy.dead) 
{
    score++;
    score++;
    roachLevel.score_txt.text = String(score);
    enemies.splice(i,1);
} 



     else // Enemy is still alive and moving across the screen
    {
        //rotate the enemy between 10-5 degrees
        tempEnemy.rotation += (Math.round(Math.random()*.4));
        //Find the rotation and move the x position that direction
        tempEnemy.x -=  (Math.sin((Math.PI/180)*tempEnemy.rotation))*tempEnemy.speed;
        tempEnemy.y +=  (Math.cos((Math.PI/180)*tempEnemy.rotation))*tempEnemy.speed;
        if (tempEnemy.x < 10)
        {
            tempEnemy.x = 11;
        }
        if (tempEnemy.x > stage.stageWidth - offset)
        {
             tempEnemy.x = stage.stageWidth - offset;
        }
        if (tempEnemy.y > stage.stageHeight)
        {
            removeEnemy(i);

            lives--;
            roachLevel.lives_txt.text = String(lives);
        }
    }
}
}
function():void
{
敌人:电影唇;
对于(变量i:int=0.length-1;i>=0;i--)
{
敌人=敌人[i];
如果(敌人死了)
{
分数++;
分数++;
roachLevel.score_txt.text=字符串(分数);
3.拼接(i,1);
} 
否则//敌人还活着,正在屏幕上移动
{
//将敌人旋转10-5度
tempTowner.rotation+=(Math.round(Math.random()*.4));
//找到旋转并将x位置移动到该方向
tempfound.x-=(Math.sin((Math.PI/180)*tempfound.rotation))*tempfound.speed;
tempfound.y+=(数学cos((数学PI/180)*tempfound.rotation))*tempfound.speed;
如果(温度x<10)
{
temp.x=11;
}
如果(tempDeffire.x>stage.stageWidth-偏移)
{
tempEngly.x=stage.stageWidth-偏移量;
}
if(temp.y>stage.stageHeight)
{
removeEnemy(一);
生命--;
roachLevel.lives_txt.text=字符串(lives);
}
}
}
}

我认为简单地替换
var-tempboyer=buzzers[I]
temp敌军=敌军[i]
将解决您的问题您已经解决问题了吗?是的,非常感谢:)太好了,不客气:)