[EMAIL PROTECTED] wrote:
This is my first experience use the mailing List so I hope this makes sense!
My question is more of a conceptual one regarding oop best practises. If
I have a class which attaches a clip to the stage how can I attach functions
to clips nested inside this clip. Putting code on the attached clip?s timeline
is wrong, I can use;

myClip.MyChildClip.onRelease = function() { stuff };

It works, but seems fundamentally wrong, as I understood it was bad practise
to add methods to an object dynamically. Should I make the class listen for
clicks on the nested clip or is there another solution?

I don't see anything wrong with that. The only thing i would do is to use Delegate instead of the function declaration so that you can control the scope of execution.

It might make sense to contain the behaviour of this child clip into a class of its own if its used for more than just event notification, but theres no hard rules as to when you should do this.

Personally I would think about what the child clip is doing. What are its responsibilities. If they can be neatly contained in a Class which can encapsulate the implementation details away from the users of the child clip then I would make a new Class for it.

The only other point to choose here is more a matter of style, do you inherit from movieclip or do you use composition. I avoid inheriting from movieclip because i feel its more trouble than its worth once you start creating subclasses and dealing with initialization order.

thanks,

Martin
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to