as3 error that i do not understand

Posted on 2007-07-30
Last Modified: 2012-05-05
i am learning as3. i try to load  variables from a php file. i wrote this code according to some tutorial. what i test the movie i get the error message:

1037:packages cannot be nested.

i look at the code and i cannot see where is a nested package:

package {
      import flash.utils.trace;
      public class loadingas3 {
            public function loadingas3 () {
                  //create the URLLoader instance to be able to load data
                  var loader:URLLoader = new URLLoader();
                  //define the event handler to perform once the loading is complete
                  loader.addEventListener(Event.COMPLETE, handleComplete);
                  //tell the loader to load url-encoded variables: that is critical for this job
                  loader.dataFormat = DataFormat.VARIABLES;
                  //now, load the data
                  loader.load(new URLRequest("loadingas3.php"));
            private function  handleComplete (event:Event):void {
                  //cast the event target as a URLLoader instance, because that is what made the event to happen.
                   var loader:URLLoader = URLLoader(;
                   //trace the variables that was loaded by referencing the variable name from the data property of the URLLoader instance
                   trace("sometext=" +;


can anyone help?

best regards

Question by:derrida
    LVL 39

    Expert Comment

    hi, have you managed to come right on this?
    is this an external script file yeah?
    LVL 1

    Author Comment


    yes it is external and i could not solve the problem.

    so i`m in the dark:)

    best regards

    LVL 39

    Expert Comment

    ur file is right?
    what's your folder setup?
    i'm not sure here, not working in as3 myself, but i'm thinking maybe (not that is answers the question why ) create a named package.
    when does this error actually come up? when you compile or when you run, how are you calling these classes?

    Accepted Solution

    Hi --

    I ran in to this same problem and finally found the "How to Use the Examples" portion of the Adobe Flash help files.

    What you need to do is save the ActionScript file as the name of the class, for example "MyClass." Then you set the Flash movie "Document Class"  (FILE-->PUBLISH SETTINGS-->FLASH-->SETTINGS) to "MyClass." You do not need to call/refer to/load the ActionScript file in the Flash movie -- it will do it automatically for you! Just make sure the FLA and the AS file are both in the same directory.

    Hope this works!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
    The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
    The goal of the tutorial is to teach the user how to how to record live broadcast.
    This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now