views:

93

answers:

2

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 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?

+2  A: 

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

George Profenza
Hi George, the parent is actually just the stage. The movieClips are all on the stage. It's a zoom-slider which communicates with the actual timeline. I like the idea to do things event driven.For function callbacks timeline and zoom slider need to still somehow know each, no? Which would again boil down to establishing a reference through parent.otherClip.
vpdn
George Profenza
A: 

try (parent as Object) anyway the dispatch event approach is much better.

antpaw