【问题标题】:AS3 Get width of playerAS3 获取播放器的宽度
【发布时间】:2012-12-14 09:12:20
【问题描述】:

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

   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

【问题讨论】:

    标签: actionscript-3 class object actionscript width


    【解决方案1】:

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

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

    public class Player extends MovieClip {
    
       private var playerHalfWidth:int;
    
       public function Player() {
    
         playerHalfWidth = this.width/2;
       }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      • 2012-10-22
      • 1970-01-01
      • 2010-12-09
      • 1970-01-01
      • 2015-02-16
      • 2010-12-09
      相关资源
      最近更新 更多