0

当按下按钮时,我想将我的类与文档相关联。我怎样才能以编程方式做到这一点?到目前为止,我已经尝试过这种方法:如何以编程方式将 flash .fla 文件与文档类关联?编译器告诉我没有名为 getDocumentDOM() 的函数。我还应该尝试什么?

4

1 回答 1

1

The document class is fixed, but you can easily instantiate new classes and add or remove them on the main timeline.

As someone commented, this is a design problem. Instead of using frames on the main timeline, select the content of your first frame and convert it into a library symbol and export it for ActionScript with a class name like "StartScreen".

You can then have the constructor of your main document class call var start_screen:StartScreen = new StartScreen(); addChild( start_screen ); to instantiate it on the main timeline. You'll have to attach an event listener to the button, such as start_screen.start_button.addEventListener( MouseEvent.CLICK, handler, false, 0, true );. Your handler function can then call removeChild( start_screen ); and add some other content in its place.

于 2013-04-30T19:29:59.090 回答