未定义的属性的访问? ActionScript 3的属性、未定义、ActionScript

2023-09-08 15:10:53 作者:哥哥的小草莓

我是编程的东西,当我以为一切都不错,不错,闪光灯抛出一个错误给我!?

起初我是目瞪口呆。然后检查我的code后,我看不到的罪魁祸首。所以我所做的就是简单下来,并改变它只是一个跟踪语句。

我仍然但是得到错误。我不知道什么是错的。

 包{

     进口的flash.display.MovieClip;
     进口src.data.DActors;

     公共类的DocumentClass扩展影片剪辑{

        公共变种dActors:DActors =新DActors;

        公共职能的DocumentClass(){
        跟踪(dActors);
        跟踪(主);
        }

    }

}
 

这是DActors类:

 包src.data
{
  公共类DActors
   {
       公共变种我:INT = 1;

      公共职能DActors();
       {
          跟踪(箱);
       }

  }

}
 

一些余地,我不知道的东西?

哦,对了,它引发了'我'没有定义!?

编辑:其实,我没有意识到真正的问题,凭啥是我的构造函数不接受变量

 包src.data
 {
公共类DActors
{
    公共变种演员:阵列=新的Array();
    公共变种dActor:DActor =新DActor();

    公共职能DActors();
    {
        actors.push(dActor);
    }

}
 
actionscript –

}

输出:

1120:未定义的属性演员访问

1120:未定义的属性dActor的访问

????这让我担心很大。无论是我的眼睛骗了我还是我失去了一些非常基本的。

解决方案

 公共职能DActors();
 

构造函数不会与结束。(分号)

I was programming something and when I thought everything was nice and good, Flash throws an error to me!?

At first I was dumbstruck. Then after checking my code, I couldn't see the culprit. So what I did was 'simple it down', and changed it to just a trace statement.

I was still however getting the error. I don't know what is wrong.

   package  {

     import flash.display.MovieClip;
     import src.data.DActors;

     public class DocumentClass extends MovieClip {

        public var dActors:DActors = new DActors;

        public function DocumentClass() {
        trace (dActors);
        trace ("Main");
        }

    }

}

This is the DActors Class:

package src.data 
{
  public class DActors
   {
       public var me:int = 1;

      public function DActors();
       {    
          trace(me);
       }

  }

}

Some scope I'm not aware of or something?

Oh, and by the way, it throws that ''me' is not defined'!?

EDIT: Actually, I failed to realize the real problem, why the hell is my constructor not accepting variables!

 package src.data 
 {
public class DActors
{
    public var actors:Array = new Array();
    public var dActor:DActor = new DActor();

    public function DActors();
    {   
        actors.push(dActor);
    }

}

}

outputs:

1120: Access of undefined property actors.

1120: Access of undefined property dActor.

???? This worries me greatly. Either my eyes are fooling me or I'm missing something very basic.

解决方案

public function DActors();

Constructor function will not end with ;(semicolon).