How to use two .as files in Flash using actionscript 3?

偶尔善良 提交于 2020-01-07 03:21:10

问题


I can only specify a single .as file,how can I have 2 classes in it?


回答1:


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".



来源:https://stackoverflow.com/questions/4232857/how-to-use-two-as-files-in-flash-using-actionscript-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!