A file found in a source-path can not have more than one externally visible definition

A file found in a source-path can not have more than one externally visible definition.

What it means in my case was that I had code outside of the class but inside the package. Look at the code below.

Actionscript:
  1. package com.test.managers
  2. {
  3.  
  4.     public interface IMyInterface
  5.     {
  6.        
  7.     }
  8.    
  9.     // these should be inside the brackets above
  10.     public var width:String;
  11.     public var height:String;
  12.     public var x:int;
  13.     public var y:int;
  14.     public var url:String;
  15.     public var htmlText:String;
  16.    
  17. }

A simple mistake. When I put the declarations inside the class code where it was supposed to go the error message resolved.

I also ran into this when I tried to add a utility class inside a package. This is the correct way to add it:

Actionscript:
  1. package com.package
  2. {
  3.    public class MyClass()
  4.    {
  5.    }
  6. }
  7.  
  8. internal class Utility
  9. {
  10.    public function Utility()
  11.    {
  12.    }
  13. }

Please reply in the comments below if this helped you or not

17 Responses to “A file found in a source-path can not have more than one externally visible definition”

  1. Jre says:

    Thanks for the help Judah.
    This definitely helped me out.
    I probably would have spent a lot of time trying to figure out something much more complex and of course in the end it was really simple!
    Thanks for taking the time to post this :)

  2. Thanks, it was really helpful :-)
    Perhaps the compiler needs more clear, more self-explaining error messages.

  3. Bruce Hopkins says:

    Wow, Judah, thanks a million. This really helped me out a lot. Happy new year!

  4. Helliax says:

    Thanks a lot for writing up this example/fix.

  5. Quinton says:

    Looks like it will also be thrown if you don't define constructors for your classes inside. Happy new year.

  6. eme says:

    UAAA!!!
    I love you!

  7. Maik says:

    Thanx!

    Applied for me too!

  8. eme says:

    oh sh..t!
    you saved me again!
    mine is a fish memory...

  9. Adam says:

    Thanks a million for this Judah, I couldn't figure what was going wrong and had been pulling my hair out for the past hour ;-)

    Legend!

  10. denverwahn says:

    Thank you for posting stuff like that! My hero!

  11. Ryan says:

    Thanks for posting the solution, I had no idea what I did wrong.

  12. Debasish says:

    This is really helpful... Thanks a lot for this post..

  13. Federico says:

    Daaaaaaamn!!!

    Thank you sooooo mutch!

  14. Lacos says:

    awesome!!!!!!!!!!

    worked for me 2

    thank you!

  15. qq says:

    But class Utility can not extends any class

  16. DELL says:

    The error will also occur when you will write the private class into the package area.

    I mean...

    package
    {
    public class abc
    {
    }
    class xyz
    {
    }
    }

    The right way is....

    package
    {
    public class abc
    {
    }
    }
    class xyz
    {
    }

  17. Asadullah says:

    Thanks Sir I was wondering why this problem is coming and I got this solution.

    Thanks again
    Asadullah

Leave a Reply