这位于公共类中,可以找到播放器宽度的一半:
public class Player extends MovieClip
{
private var playerHalfWidth:int = this.width/2;
我收到此错误:
1119:Access of possibly undefined property width through a
reference with static type class
答案 0 :(得分:0)
您甚至在创建播放器对象之前尝试引用this
。
将它移动到构造函数中,将是正确的方法:
public class Player extends MovieClip {
private var playerHalfWidth:int;
public function Player() {
playerHalfWidth = this.width/2;
}