huy.gamedev
huy.gamedev

Reputation: 1

Error accessing a packaged class, 1046: Type was not found or was not a compile-time constant

I know this question has been asked countless times on SO, but mine is just weird.

I have a package called critters for the characters in my game.

Of all the classes in this package, one (ACustomSocket) encountered 1046 error when I declare it in my code. Dog is in the same package but does not get the error.

package{
  import critters.*;
  // all necessary imports follow

  public class GameGUI extends MovieClip {
    ...
    private var socket:ACustomSocket;
    private var dog:Dog;
    ...
  }
}

Why is there such a difference? Here's how ACustomSocket is declared.

package critters {

    import flash.errors.*;
    import flash.events.*;
    import flash.net.Socket;

    class ACustomSocket extends Socket {
        private var response:String;
        public function ACustomSocket(host:String = null, port:uint = 0) {
           ....
        }        
    }
}

And here Dog.

package critters {
    import flash.display.MovieClip;

    public class Dog extends MovieClip {

        // Initialization:
        public function Dog() {
           ...
        }
    }
}

Upvotes: 0

Views: 289

Answers (1)

Patrick
Patrick

Reputation: 15717

Well make your class ACustomSocket Public so other package can use it :

public class ACustomSocket extends Socket {...}

Upvotes: 3

Related Questions