Multiple top level package declarations

The "Programming Adobe ActionScript 3.0" states in chapter 4 "ActionScript Language and Syntax", "Packages and Namespaces", "Creating Packages" that you can declare at the top level of a package multiple variables, functions, and namespaces in addition to a single class as long as only one is declared "public".
However, in Flash when I declare a public class and any other variable or function either with the "internal" attribute or no attribute, I get this error:
5006: An ActionScript file can not have more than one externally visible definition: test.function1, test.Test
The package code is as follows:
package test
    internal function function1():String
        return "Function1()";
    public class Test
The same thing happens if I replace the function with an internal variable declaration. According to the manual, any declaration with the "internal" attribute should not be externally visible outside the package. Only the "public" class declaration should be externally visible.
Can anyone clue me in as to why I get this error?

That is not the situation described by the quoted manual section that I am trying to recreate.
It clearly says:
"In ActionScript 3.0, you use the package statement to declare a package, which means that you can also declare variables, functions, and namespaces at the top level of a package. You can even include executable statements at the top level of a package. If you do declare variables, functions, or namespaces at the top level of a package, the only attributes available at that level are public and internal, and only one package-level declaration per file can use the public attribute, whether that declaration is a class, variable, function, or namespace."
The data properties and class you have decleared are outside the package within the ActionScript file, and not at the top level of a package. The "public" attribute is not available outside the package at all.
What I wish to know is why the quoted internal declarations at the top level of the package generate the quoted error.
However, I am beginning to believe that the documentation is in error and that what it is actually describing IS the situation you just described. When the manual says "top level of the package", it really means "top level of the ActionScript file outside the package", and when it says "the only attributes available at that level are public and internal", it really mans "the only attribute available outside the package declaration is internal. At the top level of the package, only one declaration may be made, it must have the same identifier as the ActionScript file name, and it can have either the public or internal attribute. Code within the same file but outside the package declaration can not access an internal declaration in the package declaration."
Actually, the whole paragraph would need to be re-written to clarify the issue and to unambiguously distinguish between "top level of a package" and "top level of an ActionScript file outside the package declaration".
As a concrete example - two ActionScript files:
MCTest.as is saved in the same directory as MCTest.fla, and the document class of MCTest.fla is set to "MCTest".
package
    trace("MCTest package code.");
    import flash.display.MovieClip;
    import test.Test;
    public class MCTest
    extends MovieClip
        trace("MCTest class code.");
        function MCTest()
            trace("Created Class MCTest: " + Test.StaticMessage);
trace("MCTest outside package code");
Test.as is saved in a sub-directory called "test".
package test
    trace("test.Test package code");
    public class Test
        public static const StaticMessage:String = "Test: Hello World!";
        trace("test.Test class code");
var myField:String = "myField";
function myFunction():String
    return "myFunction";
trace("test.Test outside package: " + myField + ", " + myFunction() + ", " + test.Test.StaticMessage);
The resultant trace output is:
MCTest class code.
MCTest package code.
MCTest outside package code
test.Test class code
test.Test package code
test.Test outside package: myField, myFunction, Test: Hello World!
Created Class MCTest: Test: Hello World!
It is interesting to note that the package and outside package code are executed AFTER the class code.
That seems to make more sense. You can only declare one class, variable, function, or namespace at the top level of a package with the same identifier as the file name, public or internal, and you can include executable code. At the top level of the ActionScript file outside the package declaration, you can only declare internal classes, variables, functions, and namespaces, and you can include executable code, none of which are within the package nor have access to any package internal declarations.
The problem, therefore, would seem to be an incorrect manual. Does anyone actually know if this is accurate and the intended behavior?

Similar Messages

  • Multiple Top-Level Realms in Access Manager via AMconfig?

    Is it possible to configure multiple top-level realms in Access Manager via AMconfig? It is not possible through the UI.

    Hi!
    How about this:
    String adminDN = (String)AccessController.doPrivileged(new AdminDNAction());
    String adminPwd = (String)AccessController.doPrivileged(new AdminPasswordAction());
    adminToken = adminManager.createSSOToken(new AuthPrincipal(adminDN), adminPwd);
    hth Chris

  • What is top level class declaration in java?

    What is top level class declaration in java?

    The declaration of a class that's not nested inside any other class.

  • ASDoc: Top Level Package

    Hi folks,
    after searching around quite a while without success I am
    wondering if you could help me with a question.
    We have documented our code and used the "-package" parameter
    with asdoc for our package description. However, how can we add the
    description of the Top Level package into ASDoc? With the
    "-package" parameter I can only address "real" packages, but not
    the Top Level package.
    Thanks for your help!
    Regards
    Michael

    Hi folks,
    after searching around quite a while without success I am
    wondering if you could help me with a question.
    We have documented our code and used the "-package" parameter
    with asdoc for our package description. However, how can we add the
    description of the Top Level package into ASDoc? With the
    "-package" parameter I can only address "real" packages, but not
    the Top Level package.
    Thanks for your help!
    Regards
    Michael

  • How to avoid multiple top level navigation nodes ?

    Dear portal experts,
    If a user is assigned to multiple portal roles, which contain partially the same worksets, the user gets these worksets doubled in the top level navigation.
    Can this be avoided ? The portal should check the user roles and show each workset only once.
    Thanks,
    Johannes

    Hi,
    you have to set Merge ID attribute to the worksets.
    Regards,
    Ladislav

  • SetCursor use for multiple top level windows (JFrame)

    Hello,
    I have an application with many top level windows, most of which are running under a single
    thread. I'm trying to implement a class to toggle the cursor (normal<->busy) for any window
    that is present in the application.
    I can't seem to get the cursor to change for any window other than the main window. I'm providing
    below the class that's used to register the windows and set the cursors.
    What am I missing?
    import java.awt.Cursor;
    import java.util.ArrayList;
    import javax.swing.JComponent;
    import javax.swing.RootPaneContainer;
    public class AppWindows {
        ArrayList<WinInfo> windows;
        /** Creates a new instance of AppWindows */
        public AppWindows() {
            windows = new ArrayList<WinInfo>();
        public void add(JComponent window, String title) {
            WinInfo win = new WinInfo(window, title);
            windows.add(win);
        public void delete(JComponent window) {
            windows.remove(window);
        public void deleteAll() {
            windows.clear();
        public void setBusyStatus(boolean busy) {
            for(int i=0; i<windows.size(); i++) {
                JComponent j = windows.get(i).getWindow();
                RootPaneContainer root = (RootPaneContainer)j.getTopLevelAncestor();
                if(busy == true) {
                    root.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    root.getGlassPane().setVisible(true);
                else {
                    root.getGlassPane().setCursor(Cursor.getDefaultCursor());
                    root.getGlassPane().setVisible(false);
    class WinInfo {
        private JComponent win;
        private String title;
        public WinInfo(JComponent win, String title) {
            this.win = win;
            this.title = title;
        public JComponent getWindow() {
            return win;
    }Bill

    I would very much like to know how to avoid this also!!!

  • ADFS server pointing to multiple top level domains

    Hi,
    I have two separate Active Directory Forests setup in my environment (domainA.net and domainB.net) Each forest has a few child subdomains.
    I would like one ADFS website to allow authentication for both AD forests in my environment.
    Is there a way for me to configure that?
    Please advise.
    Thanks,

    If there's no forest trust between the two AD forests, then you'll need an additional AD FS installation in the forest where it doesn't currently exist. For example, if the AD FS instance exists in ForestB, then a separate AD FS instance is required in
    Forest A.. from the AD FS setup in Forest B, the Forest A AD FS instance can be configured as a claims provider and Forest B is configured as a relying party on the Forest A instance.. In other words, you're building a circle of trust.. this can be via legacy
    means (using a forest trust or two-way trust subject to your requirements) or via a federation trust using AD FS, via the claims provider approach I described... post back if you need more info..
    http://blog.auth360.net

  • How do I use CreateBookmarksFromGroupTree and NOT get a "temp_" for my top level?

    I have a report that I have created that uses uses groups and I wanted export a PDF using the CreateBookmarksFromGroupTree option. While that works, I get an ugly top level bookmark name that starts with "temp_" then followed by two GUIDs "temp_13fef8e3-30ec-4bc5-ba77-b55d23c95e8f {87823BCB-7789-407C-8A7F-5096BE07A83E}".
    So, how do I:
    1) Get rid of this top level so it matches the Crystal Viewer (which has multiple top level bookmarks)
    2) Put in a name of my own choosing as the top-level bookmark.
    <!break>
    Any help or suggestions would be appricated.
    Thanks,
    Jim

    I would very much like to know how to avoid this also!!!

  • Declaring top level classes instead of subclasses

    I seem to have misunderstood something very basic.
    It's always better, where possible, to declare the top-level class instead of the sub-class, right?
    Ok, then why do I have the following problem?
    I declare, from the JavaMail API the following:
    Message theMessage = new MimeMessage(session);instead of declaring directly the subclass like this:
    MimeMessage theMessage = new MimeMessage(session);but when I use a method which is only found in the MimeMessage class I get a compile error.
    [javac] 189.           theMessage.setSubject(subject, "iso8859_1");
    [javac] <-------------------------------->
    [javac] *** Error: No match was found for method "setSubject(java.lang.String, java.lang.String)".
    Have I really misunderstood something so basic?? Surely the compiler knows that theMessage is an instance of MimeMessage??
    Any clear explanation to explain why I get this compile error would be gratefully received. I have been faithfully declaring top-level classes instead of subclasses in my code, but if the compiler doesn't let you do so, then what's the point?

    Ok, my confusion was started by an article on the
    Collection classes which stated that:
    Map theMap = new HashMap(); was better
    programming practice.
    Yep.
    But the Map class is an Interface, right? - Whereas
    Message is a normal class with subclass MimeMessage.
    I think that's where my confusion started.Well, this isn't really a class vs. interface difference. It goes to which class (or interface) is the "highest" (closest to Object) and still has all the public interface you need.
    There are cases where you'll declare a variable to be of a base class type like Message.
    You just need to get into the habit of separating the left side of the = from the right side. On the left, you put the bare minimum that completely meets your needs. You say, "I need a List" or "I need a Map" or "I need a SortedMap" (a subinterface of Map) or "I need a Message" or "I need a MimeMesage".
    Then, on the RHS =, you decide which particular class best implements the public interface that you said you need (by declaring it on the LHS). "For my Map, I'll use a HashMap." "For my Message, I'll use a MimeMessage." "For my MimeMessage, I'll use a MimeMessage".

  • Running multiple instances of a top level vi

    The following question is copied from a 1999 post which I am also interested in an answer to. It wasn't answered in '99, but maybe there are more people around today who could comment;
    "I am interested in running multiple copies of a top-level vi in Labview
    operating under Windows95/98/NT much like you could run several copies of
    notepad.exe simultaneously. Whenever I attempt to start a second copy of a
    vi (or .exe), in either the development or runtime environment, Labview just
    brings the first copy to the foreground. Is it possible to alter this
    behavior?"

    I think it is not a bug but an "open feature". What to do if there is 2 or more calls to the same VIT on the diagram? Should a new instance be created for each node or the same instance reused? It depends of the programmer's intents... The problem has been swept under the carpet allowing only one subVIT instanciation per diagram.
    Back to the topic, one would have to be very careful to code an application where the same hierarchy of VIs has to run in multiple copies in parallel. User interface VIs has to be instanciated dynamically user VITs. What to do with subVIs with unitialized shift registers that shouldn't share their data amongst different hierachies? It is doable but requires a careful design. However for simple user display and
    input, a VIT does the job.
    The easiest way is to duplicate and run an executable file copy. That is because when a second instance of a LabVIEW executable is run, it detects the already running instance, passes the control to it and quit. With a different file copy of the executable, the application can be relaunched with its own application space where you can run the same hierarchy of VIs without conflicts.
    LabVIEW, C'est LabVIEW

  • Error 1127 occurred when open multiple instances of the same LabVIEW top level VI?

    I try to open multiple instances of the same LabVIEW top level VI, After search some messages in the forum,I know it should use vi template, But error 1127 still occurred when i used template(In my program, Click menu file->new). The information about error 1127 is  "Cannot instantiate template VI because it is already in memory".
    Here is my code. can any one help me? Thanks.
    Attachments:
    test.zip ‏13 KB

    Hi,
    You are trying to obtain a path from the VI location but the VI has no location because its an instance of the VIT and therefore the path is <not a path>.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Issue with having to declare fixed width for my top level floated LI in horizontal menu

    Hi and thanks for taking a look at my problem:
    I am having trouble getting my sub menus to display correctly in IE.
    Originally i didn't declare a fixed width for my top level li and it displayed perfectly in all browsers except IE.
    If i don't declare a fixed width for my floated floated elements, IE treates the top level li as the same width as the ul they contain (which I don't want). So I declared a width for the ul.MenuBarHorizontal li to be 80px, which is close to the minimum width that i want to use for the top level list items. However, in actual fact, the top level list items all have individually declared widths in the classes they are assigned.
    How can i re-write the html or CSS so that the browser, mainly IE, reads the correct widths for the top level ist li??
    Here is a link to the page with the problem
    Thanks in advance if anyone can help me out.

    Hi Beth,
    thanks so much for your repsonse.
    I will take your notes and advice and see if i can apply it to the actual page i was referring to. It seems you were now looking at a completely different page with a different (albeit spry) horizontal menu.
    Again, i truly appreciate your time and advice.
    Thanks!

  • Failed to load XML from the package file "" due to error 0xC00CE556 "Invalid at the top level of the document.Line.

    Using Installation wizard to deploy SSIS packages from DEV server to QA server package store cause this error;
    Failed to load XML from the package file "" due to error 0xC00CE556 "Invalid at the top level of the document. Line 773, Column 93". This happens when loading a package and the file cannot be opened or loaded correctly into XML document.  This can be the
    result of either providing an incorrect file name to the LoadPackage method or the XML file specified having an incorrect format.  Please who have the idea of how this issue can be resolved?BI Developer

    Hi ,
       for this Error one and only one solution 
    go to view Code, line number and Column number shown in error message,
    and Remove code from there till last and save it,  it happens when we are moving Package from one server to another server. and VS adds some lines of code at the bottom of package
    something like this 
    andles="1" allownudging="1" isannotation="0" dontautolayout="0" groupcollapsed="0" tabstop="1" visible="1" snaptogrid="0"&gt;
        &lt;control&gt;
          &lt;ddsxmlobjectstreaminitwrapper binary="00080000921400008c040000" /&gt;
        &lt;/control&gt;
        &lt;layoutobject&gt;
          &lt;ddsxmlobj&gt;
            &lt;property name="LogicalObject" value="{BBFB0E
    Remove this code and save package it will work.  
    hope this will help to Developers who are searching for same ......... :) 

  • [svn:fx-trunk] 9924: Empty design layers with id' s are now persisted and declared as top level properties.

    Revision: 9924
    Author:   [email protected]
    Date:     2009-09-02 09:11:03 -0700 (Wed, 02 Sep 2009)
    Log Message:
    Empty design layers with id's are now persisted and declared as top level properties.
    QE notes: None
    Doc notes:  None
    Bugs: SDK-22904
    Reviewer: Paul
    Tests run: Checkin
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-22904
    Modified Paths:
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/InterfaceCompiler.java
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/analyzer/SyntaxAnalyzer.java
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/builder/DocumentBuilder.java
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/dom/DocumentNode.java
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/MxmlDocument.java

    I seem to have fixed it by putting <div  class="clearfloat"></div> after the navigation bar?

  • Running multiple vi's in top level app at same time.

    hello, i am wondering on how to run multiple vi's under the same top level application.  if i have a top level application that has multiple buttons that call other vi's, is there a way to minimize one of the sub vi's and open another.  i keep having problems because i think that the top level application needs the first sub vi to close befor you can call another sub vi.  i attach an example i found in the ni examples as an example.  thank you.
    Attachments:
    Dynamic Load Example.vi ‏52 KB

    Thank you for the response.  I tried to use this feature but i think i am doing it wrong.  Do you put the method in the sub vi's or in the top level application.  also what should you wire to the Auto Dispose Ref input for the Run VI method.  Thank you

Maybe you are looking for

  • External hard drive is not working on airport time capsule even after 7.7.2 firmware update.

    External hard drive is not working on airport time capsule even after 7.7.2 firmware update. I have the latest Airpor Time capsule 2gb. I specifically bought it so that I could have an external hardrive set up to wirelessly house my itunes library an

  • Wat is webproperties tab in smart forms

    In smart forms when we are creating a text for a window apart from general attributes,o/p options and conditions tabs we have one more tab called web properties wat is tahat and how to use it

  • How to avoid text cutting on iBooks?

    Dear All, In epub 3 when multicolumn text used means text cuts on the top and bottom margin, flows on the next page. Kindly suggest me how to avoid these type of errors in iBooks. Thanks, Muzammil

  • IPhoto and videos

    I have an Casio Exilim EX-Z50 and I love it. I have a lot of photos and small video clips that I have imported into iPhoto. The videos play fine and all but I can't export them - the menu is greyed out. I want to be able to export the files, export t

  • HT5706 Having trouble accessing iTunes store

    Got an Apple TV for Easter, hooked it up and everything seemed to be working fine, until I tried to buy a movie. Eveytime I try to buy something it says "unable to access Itunes store" How to fix?