• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

1037: Package Cannot Be Nested

LEGEND ,
Jan 07, 2008 Jan 07, 2008

Copy link to clipboard

Copied


Hi --

I ran in to the "1037: Package Cannot Be Nested" error when using the sample
code in Flash help and found the "How to Use the Examples" portion of the
Adobe Flash help files to finally get my answer. It appears to be an issue
many others have come across so I thought I would explain in more detail how
to solve this problem.


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.



Rich



TOPICS
ActionScript

Views

4.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 07, 2008 Jan 07, 2008

Copy link to clipboard

Copied

Richard,

> I ran in to the "1037: Package Cannot Be Nested" error when
> using the sample code in Flash help

Ah, good one! Yes, thanks for bringing this up. A number of the
current 3rd party ActionScript books -- and, as you pointed out, most of the
sample code in the docs -- is written in the form of class files. I've
heard from a number of people who have tried to copy/paste such code into
keyframes, then see the 1037 compiler error.

In ActionScript 3.0, all SWFs have a Document class one way or the
other. If you don't assign one yourself, such as the MyClass.as you
mentioned, the SWF will receive a default Document class by the name of
MainTimeline. Which means the SWF's code is already declared inside a
package (automatically). The introduction of a second (seemingly original)
package declaration in timeline code cause those two packages to be nested,
which is not allowed.


David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 07, 2008 Jan 07, 2008

Copy link to clipboard

Copied

LATEST
Richard,

Woops, meant to add one more point.

Many of the code samples in class format can still be used in keyframe
code, but you have to rewrite them in terms other than a class structure.
In other words, drop the package declaration, the class declaration, and
member attributes like public, private, and the like. Sometimes it's not
worth the effort! 😉 But then again, sometimes it is, if you're going to
end up using a particular approach in timeline code. You just have to
"lift" it from its class trappings.


David Stiller
Contributor, How to Cheat in Flash CS3
http://tinyurl.com/2cp6na
"Luck is the residue of good design."


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines