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

as3 - Changing position checking for in IF statement

我正在尝试使用 IF 语句捕获 X.Y 位置,如果坐标为真,我希望它继续到下一组坐标。在下面的代码中,我尽了最大努力,但我不断收到 "Cannot assign to a non-reference value." 错误。

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;
            }

    }

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

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

因此您的代码将变为:

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;
        }
}