views:

126

answers:

2

Hi,

is there a way to create a class inside the main .fla file of a flash application? If I try to define a class directly in the action layer of the .fla, I get the error: "classes must not be nested". Alternatively, if I try to define a package and the class inside, I get "packages must not be nested".

I know I can reference an external .as file as the "Document class" but I was wondering if there was a way to put the class directly into the .fla.

Thanks!
Zoltan

+1  A: 

Classes must be defined with a package in .as files with the exact filename as the class

// Filename: MyClass.as
package {
    public class MyClass {
    }
}
Rhysyngsun
A: 

You can not create a class in the timeline. The Flash compiler treats the timeline as a class itself and you can not nest classes within classes.

Allan
The argument that the timeline is treated as a class itself makes sense. Thanks!
Zoli2xa
No worries :), if you use a good decompiler you will be able to see how Flash compiles the timeline.
Allan