00:00
00:00
Newgrounds Background Image Theme

perilsofafrog just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

"1037: Packages cannot be nested"

6,889 Views | 6 Replies
New Topic Respond to this Topic

"1037: Packages cannot be nested" 2009-11-06 17:23:51


OMFG!!!!!!

im finaly taking everybodys advice and converting to AS3, but I always get the error:
1037: Packages cannot be nested

At the end I copied the code directly into my flash and i got the same error -.-

AS3, on main timeline:
package 
{
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class Starter_1 extends Sprite 
	{
	       private var tField:TextField;
	       public function Starter_1 () 
	       {
	               myTest();
	       }
	       private function myTest():void 
	       {
	               tField = new TextField();
	               tField.autoSize = "left";
	               tField.background = true;
	               tField.border = true;
	               tField.x = 20;
	               tField.y = 75;
	               tField.text = "Hello, world";
	               addChild(tField);
	       }
	}
}

BBS Signature

Response to "1037: Packages cannot be nested" 2009-11-06 17:30:16


Packages must be in their own AS file.

Each class should have its own file named the same as its class name.

Response to "1037: Packages cannot be nested" 2009-11-06 17:34:41


thats like kinda... stupid...


BBS Signature

Response to "1037: Packages cannot be nested" 2009-11-06 17:37:06


I thought the same thing when i first started using classes, and it was really hard for me to get used to. But now that i have gotten used to it, its SOOO nice, each class has its own file and it keeps me very orginized (whenever i need to change something, i know exactly where it is).

If you give it a chance im sure you will adjust the same as me, and you will love it.

Response to "1037: Packages cannot be nested" 2009-11-07 13:08:28


Fun fact, framescripts are a part of the class for the timeline they are on. And that class is already in a package, leading to this error.


Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.

Response to "1037: Packages cannot be nested" 2009-11-07 14:42:00


At 11/6/09 05:31 PM, zrb wrote: You don't write class codes on your main timeline though :

See, zrb doesn't even know AS3, and he knows what's wrong. :)

Just recreated the error, on the main timeline:

package {

}

what

BBS Signature

Response to "1037: Packages cannot be nested" 2009-11-07 15:10:40


If you're on Winblows, I recommend getting FlashDevelop for writing AS, it's a lot nicer than the Flash IDE. It even autoimports required classes if it detects a class missing.

On flash, set the document class to "in the properties panel" to "MainClass." Create a new AS file in the same directory as the (*.fla) / (*.swf), name the file "MainClass.as" and append to this to the file:

package
{
     import flash.display.MovieClip;

     public class MainClass extends MovieClip
     {
          public function MainClass():void
          {
               trace("It's working!");
          }
     }
}

package acts as the directory structure in relation to the fla / swf. the method "MainClass" works as a constructor for the "MainClass."

Hopefully that helped you out!


BBS Signature