Referencing other movieclips within actionscript class
I have externalized the actionscript code of a movieclip into a separate class files. This movieclip requires references to some other clips on the stage. What I am currently doing to reference those clips is by using Movieclip(this.parent).otherclip but somehow that开发者_Python百科 feels wrong.
Is there a better way to pass in the required references into a class extending from Movieclip inside of the constructor? Or what is the recommended pattern here?
Does the parent movie clip have a class as well ? If, maybe the parent class should manage initializing it's children.
If not, you could dispatch an event from the class your are writing, and listen for that event in the parent.
If it's something complex and performance is an issue, you could just add function callbacks.
HTH, George
try (parent as Object)
anyway the dispatch event approach is much better.
精彩评论