2015-11-13 30 views
0

當我的其中一個影片剪輯的定位與另一個定位相同時,我需要發生一些事情。這是我嘗試使用的代碼,但不起作用。說:「賦值運算符的左側必須是變量或屬性。」ActionScript 2.0初學者,定位

instructions_txt.text = "Pomozite Macku da dodje do cigara!"; 
var speed:Number = 3; 
var pozx; 
var pozy; 

balloon_mc.onEnterFrame = function() { 

if (Key.isDown(Key.RIGHT)) { 
    this._x = this._x + speed; 
} else if (Key.isDown(Key.LEFT)) { 
    this._x = this._x - speed; 
} else if (Key.isDown(Key.DOWN)) { 
    this._y = this._y + speed; 
} else if (Key.isDown(Key.UP)) { 
    this._y = this._y - speed; 
} 
if(pozx = this._x && pozy = this._y) 
{ 


    } 
}; 
cigare_mc.onEnterFrame = function() { 
this._x = pozx; 
this._y = pozy; 
} 

回答

0

你明白我的錯誤,因爲在你的if聲明中,你已經使用了assignment operator (=)而不是equality (==)一個,所以你可以寫:

if(pozx == this._x && pozy == this._y) { 
    // ... 
} 

欲瞭解更多有關ActionScript 2的語法和基礎知識,看看here

但是,你是一個初學者,你就可以開始learning ActionScript 3(您可以使用,例如,創建一個使用AIR一些移動應用......),而不是舊的ActionScript 2 ...

希望可以幫助。

1

希望這不是爲時已晚, 我覺得你的問題是在這裏:

this._x = this._x + speed; 
this._x = this._x - speed; 
this._y = this._y + speed; 
this._y = this._y - speed; 

您應該使用2變種改變_x和_y 試試這個:

instructions_txt.text = "Pomozite Macku da dodje do cigara!"; 
    var speed:Number = 3; 
    var pozx; 
    var pozy; 
    var baseX = this._x; 
    var baseY = this._y; 

    balloon_mc.onEnterFrame = function() { 

    if (Key.isDown(Key.RIGHT)) { 
     this._x = baseX + speed; 
     baseX = baseX + speed; 
    } else if (Key.isDown(Key.LEFT)) { 
     this._x = baseX - speed; 
     baseX = baseX - speed; 
    } else if (Key.isDown(Key.DOWN)) { 
     this._y = baseY + speed; 
     baseY = baseY + speed; 
    } else if (Key.isDown(Key.UP)) { 
     this._y = baseY - speed; 
     baseY = baseY - speed; 
    } 
    if(pozx == this._x && pozy == this._y) 
    { 


     } 
    }; 
    cigare_mc.onEnterFrame = function() { 
    this._x = pozx; 
    this._y = pozy; 
    }