How to use two .as files in Flash using actionscript 3?
I can only specify a single .as
file,how can I hav开发者_StackOverflow社区e 2 classes in it?
The file (In your case, its MinPlay) you specify is called the document class.
Among the contents in the file, the file is supposed to have class a class named 'MinPlay' which extends either a Sprite or Movieclip. Something like
package
{
public class MinPlay extends Sprite
{
// Constructor??
}
}
So basically when you type in the document class as above, the constructor will be called. It is totally up to you to initialize new classes, add event listeners or do whatever you like from here on. You may create any number of class files (as files) & link them all together, it's straight foreward OOP from here on.
About your question. Well about that, consider that every programming language needs to have a single entry point, which in the case of flash is the document class. Flash is designed to do what you would already do with actionscript, or rather write code for you. So document class is something like saying "let me carry on from here".
精彩评论