as3 - 在IF语句中更改位置检查

时间:2018-03-09 20:22:15

标签: actionscript-3

我试图用IF语句捕捉X.Y位置,如果坐标为真,我希望它继续下一组坐标。在下面的代码中,我尝试了最好的但我继续得到"无法分配给非参考值。"错误。

public function onDd(event:TimerEvent):void  
    { 
        if (this.rootClass.world.strMapName == "test" && a1.x = a1.x = 327.1 && a1.y = 249.65)
            {
                a1.x = 360.7; 
                a1.y = 204.25;
            }
        else if (a1.x = 410.15 && a1.y = 204.25)
            {
                a1.x = 360.7; 
                a1.y = 204.25;
            }

    }

1 个答案:

答案 0 :(得分:0)

您使用了错误的比较运算符

如果您想比较两个值,则必须使用=====

所以你的代码将成为:

public function onDd(event:TimerEvent):void { 
    if (this.rootClass.world.strMapName == "test" && a1.x == 327.1 && a1.y == 249.65) {
            a1.x = 360.7; 
            a1.y = 204.25;
        }
    else if (a1.x == 410.15 && a1.y == 204.25) {
            a1.x = 360.7; 
            a1.y = 204.25;
        }
}