伙计。所以,我刚才遇到了这个编译错误。由于有一个简单的解决方法,我当时没有找到任何相关的东西,我最终放弃了它。软件包名称与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