夥計。所以,我剛纔遇到了這個編譯錯誤。由於有一個簡單的解決方法,我當時沒有找到任何相關的東西,我最終放棄了它。軟件包名稱與getter和setters衝突嗎?
我只記得它,我現在想知道這是否真的是語言語法的一部分(我高度懷疑),還是它是一個編譯器錯誤。我對此很好奇 - 它並沒有真正影響開發,但很高興看到你們中的任何一位是否已經看到了這一點。
package view {
import flash.display.Sprite;
public class Main extends Sprite {
private var _view:Sprite = new Sprite();
public function Main() {
this.test();
}
private function test():void {
trace(this.view.x, this.view.y);
//1178: Attempted access of inaccessible property x through a reference with static type view:Main.
//1178: Attempted access of inaccessible property y through a reference with static type view:Main.
//Note that I got this due to the package name.
//It runs just fine if I rename the package or getter.
}
public function get view():Sprite {
return this._view;
}
}
}
+1。在AS3中,我的經驗法則是:不惜任何代價避免在全局標識符(包和類)與範圍標識符(變量和屬性)之間發生衝突,因爲即使上下文非常清晰,編譯器也可能會窒息。 – back2dos 2010-06-14 10:17:15
我想我應該填寫一份JIRA報告,哈哈。順便說一下,我注意到'this.view'沒有產生任何錯誤。 :P – mrkishi 2010-06-15 12:44:49