views:

120

answers:

1

I am trying to import classes to no avail.

test.fla
timeline 1: var main:Main = new Main();

main.as

package{  
    import flash.display.MovieClip;   
    public class Main extends MovieClip{  
        public function Main()  
        {  
            var _myClass:myClass;//this line will fail  
            trace("Main");    
        }
    }  
}  

myClassFile.as

package{   
   public class myClass   
   {  
       public function myClass()  
       {  
           trace("myClass");  
       }  
   }   
} 

Error: 1046: Type was not found or was not a compile-time constant: myClass.
//lets try this . . .

main.as

package{   
    import flash.display.MovieClip;   
    import MyPackage;  
    public class Main extends MovieClip{  
        public function Main(){  
            var _myClass:myClass;  
            trace("Main");    
        }  
    }
}

myClassFile.as

package MyPackage{    
    public class myClass {  
        public function myClass(){  
            trace("myClass");  
        }  
    }   
}

Error: 1172: Definition MyPackage could not be found.

All files are located in the same directory

+1  A: 

Soluition: rename the class to reflect the name of the file

myClassFile.as

package{  
  public class myClassFile  
  {  
   public function myClassFile()  
   {  
   trace("myClassFile");  
   }  
  }  
} 
shxo