user310291
user310291

Reputation: 38180

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 it's out of me!

Upvotes: 0

Views: 47

Answers (1)

sberry
sberry

Reputation: 131968

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.

Upvotes: 1

Related Questions