as3 error that i do not understand

Posted on 2007-07-30
Medium Priority
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.events.*;
      import flash.net.*;
      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(event.target);
                   //trace the variables that was loaded by referencing the variable name from the data property of the URLLoader instance
                   trace("sometext=" + loader.data.sometext);


can anyone help?

best regards

Question by:derrida
  • 2
LVL 39

Expert Comment

ID: 19660130
hi, have you managed to come right on this?
is this an external script file yeah?

Author Comment

ID: 19660634

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

so i`m in the dark:)

best regards

LVL 39

Expert Comment

ID: 19661556
ur file is loadingas3.as 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

rwmorey71 earned 500 total points
ID: 20601631
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!


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

807 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