我目前正在学习使用单独的.as文件和类,但在阅读了很多内容后,所有内容似乎与我所阅读的内容有所不同.我发布这个问题是为了学习,而不仅仅是为了使代码工作.这里的例子是我真实项目的测试,简化再现.
我的文件"MyApp.fla"有1个框架,形状为背景,DocumentClass设置为"MyApp".该库拥有一个带有另一个背景形状的1帧符号"Page1",其类设置为"Page1"
MyApp.as:
package {
trace("1: DocumentClass file, before class");
import flash.display.MovieClip;
public class MyApp extends MovieClip {
trace("2: DocumentClass file, in the class")
public var setting1:int = 2; //this is a variable which i want to be accesible to other classes, so to the pages being loaded
private var currentPage:MovieClip; //I wanted to create this var in the constructor, but I'm afraid something will explode again :<
public function MyApp() {
trace("3: DocumentClass file, in constructor function");
currentPage = …Run Code Online (Sandbox Code Playgroud)