开发者

Flash is incapable of instantiating a class from the declaration section of another one?

I just want to do something trivial:

public class MyClass1 
{

    private var MyClass2:MyClass2 = new MyClass2();

And I got the ERROR

1046: Type was not found or was not a compile-time constant: myClass2.

Update: My class is capitalized in real. Flash doesn't accept same name which is obsviously weird: in other languages there's no problem! Why does Flash confuse the two 开发者_JAVA技巧it's out of me!


There could be 1 of two problems here.

  1. You didn't import myClass2 and it is in a different namespace (package)
  2. The more likely problem is that you are naming your variable the same as your class, and I believe that is a no-no if I remember correctly.

Try:

private var myClassInstance:myClass2 = myClass2();

which should, by the way, be more like:

private var myClass2:MyClass2 = MyClass2();

since classes should be capitalized.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜