Forum Topic: "1037: Packages cannot be nested"

(126 views • 7 replies)

This topic is 1 page long.

<< < > >>
Mad as Hell

havegum

Reply To Post Reply & Quote

Posted at: 11/6/09 05:23 PM

havegum DARK LEVEL 11

Sign-Up: 10/20/08

Posts: 386

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);
	       }
	}
}

None

TheBoob

Reply To Post Reply & Quote

Posted at: 11/6/09 05:30 PM

TheBoob NEUTRAL LEVEL 12

Sign-Up: 04/12/02

Posts: 387

Packages must be in their own AS file.

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


None

zrb

Reply To Post Reply & Quote

Posted at: 11/6/09 05:31 PM

zrb LIGHT LEVEL 11

Sign-Up: 08/08/06

Posts: 4,548

At 11/6/09 05:23 PM, havegum wrote:
AS3, on main timeline:

You don't write class codes on your main timeline though :\

As for your problem, not too sure. Looks right to me but I have limited knowledge of AS3.
Maybe you have to name your package ?

School Sux ! || As :Main || As3: Main || Animation: Main || Flash Tutorials ||

BBS Signature

Sleeping

havegum

Reply To Post Reply & Quote

Posted at: 11/6/09 05:34 PM

havegum DARK LEVEL 11

Sign-Up: 10/20/08

Posts: 386

thats like kinda... stupid...


None

TheBoob

Reply To Post Reply & Quote

Posted at: 11/6/09 05:37 PM

TheBoob NEUTRAL LEVEL 12

Sign-Up: 04/12/02

Posts: 387

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.


None

henke37

Reply To Post Reply & Quote

Posted at: 11/7/09 01:08 PM

henke37 NEUTRAL LEVEL 23

Sign-Up: 09/10/04

Posts: 3,592

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.


None

K-Guare

Reply To Post Reply & Quote

Posted at: 11/7/09 02:42 PM

K-Guare FAB LEVEL 17

Sign-Up: 05/23/08

Posts: 2,413

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 {

}

i work alone. i wore cologne.

BBS Signature

None

blah569

Reply To Post Reply & Quote

Posted at: 11/7/09 03:10 PM

blah569 DARK LEVEL 21

Sign-Up: 01/18/05

Posts: 2,700

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!

PHP: Main | AS3: Main | Get Firefox | Host large files (fast and free)!
"Thank you for learning me English."

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 04:12 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!