3 Replies Latest reply on Jun 4, 2007 4:19 PM by kglad

    Help with custom class creation

    JoMasta
      I have a very simple program where all I want to do is create an instance of a class in another file.

      In my .fla, I have the following code in the first (and only) frame of the timeline:

      import TestClass;

      var t:TestClass = new TestClass();

      stop();

      I also have 1 actionscript file called TestClass.as, in the root dir (same dir as the .fla) with the following code:

      class TestClass
      {
      public function TestClass()
      {
      }

      public function GetName() : String
      {
      return "TestClass";
      }
      };

      I get the following errors when I run it:

      1046: Type was not found or was not a compile-time constant: TestClass.
      1180: Call to a possibly undefined method TestClass.

      I cannot get the code to recognize the other class for the life of me.

      I tried just pasting the class at the top of the .fla file (which really isn't possible with the size of my project) and I got the following error:

      1131: Classes must not be nested.

      I am currently using the trial of Flash CS3 Pro. Any suggestions would be greatly appreciated!

      Thanks!

      edit: I also get the same results if I do not import (as I do not think I should have to).