5 Replies Latest reply on Aug 18, 2008 6:36 AM by Newsgroup_User

    Multiple Classes in A Package

    wyattbiker
      Is there a way to add more than one class in a package? It seems you are not allowed to have more than one class. I don't think it makes sense to be disallowed. After all whats the sense of even having the package keyword?

        • 1. Re: Multiple Classes in A Package
          atta707 Level 2
          in a folder like com/your/company/app/util you can have as many classes as you like with a the package statement like:

          package com.your.company.app.util

          for more info, please refer to "Packages and namespaces" topic in FB help.

          ATTA
          • 2. Re: Multiple Classes in A Package
            Level 7

            "wyattbiker" <webforumsuser@macromedia.com> wrote in message
            news:g8a8bg$3qf$1@forums.macromedia.com...
            > Is there a way to add more than one class in a package? It seems you are
            > not
            > allowed to have more than one class. I don't think it makes sense to be
            > disallowed. After all whats the sense of even having the package keyword?

            Of course you can. What problem are you having that makes you think you
            can't?


            • 3. Re: Multiple Classes in A Package
              g-s-b Level 1
              I think wyattbiker is confusing "package" with a "single .as file."

              • 4. Re: Multiple Classes in A Package
                wyattbiker Level 1
                I guess worded my question badly.

                I mean inside a single package file can I add multiple classes.
                E.g. can I do something like this or do the 2 classes have to be in separate files. I read the docs and nowhere does it say one class per file in packages.
                • 5. Re: Multiple Classes in A Package
                  Level 7

                  "wyattbiker" <webforumsuser@macromedia.com> wrote in message
                  news:g8bpkq$ote$1@forums.macromedia.com...
                  >I guess worded my question badly.
                  >
                  > I mean inside a single package file can I add multiple classes.
                  > E.g. can I do something like this or do the 2 classes have to be in
                  > separate
                  > files. I read the docs and nowhere does it say one class per file in
                  > packages.
                  >
                  >
                  > package com.myutils {
                  >
                  > public class xyz {
                  > }
                  >
                  > public class abc extends xyz {
                  > }
                  > }

                  You can have multiple classes within one file, but they can't both be
                  public. Google "flex singleton pattern" for more info.