0

这位于公共类中以找到播放器宽度的一半:

   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
4

1 回答 1

0

this您甚至在创建Player对象之前尝试引用。

将它移动到构造函数中,将是正确的方法:

public class Player extends MovieClip {

   private var playerHalfWidth:int;

   public function Player() {

     playerHalfWidth = this.width/2;
   }
于 2012-12-29T10:43:18.580 回答