Accessing the Document class in AS3

后端 未结 3 811
青春惊慌失措
青春惊慌失措 2020-12-31 06:28

How can instantiated classes access the Document class?

Even after I name the Document class using the Properties bar in Flash, att

3条回答
  •  醉话见心
    2020-12-31 06:40

    The document class is not inherently a globally accessible object. If you want to call methods that are in the document class, you'll always have to pass a reference from Main to any other classes/objects that want to call its methods. A more object oriented approach would be to dispatch events from your other classes (Other) for the Main class to listen to and call an appropriate method in itself.

    If you are unconcerned about keeping a good OOP structure and want to access the document class from a display object that has been added to the display list you could try something like: stage.getChildAt( 0 );

提交回复
热议问题