Danny,
>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?
There's nothing wrong with adding methods to an object
dynamically. What's slightly dodgy is 'talking to' a child or
property of an object directly.
It's better OO practice for the object to be in charge of its
own properties, and to talk to it by some kind of accessor
method. So you might say
The original post and your reply, raised a question in my mind.
I got my start in programming with languages like Basic, Pascal, and C
(no,
not C++ or C#). I latched onto Hypercard and Supercard in the beginning of
the 90s. (Yeah, I'm showing my age.) Later, as the web moved into the
commercial sector, I got into JavaScript, followed by Director and Flash.
I brought with me a lot of line-by-line coding bad habits. As much as I
understand OOP and try to utilize OOP in my projects, I often relapse into
"scripting" mode simply because it is natural to me.
I'm much the same as you, and probably not the best person to ask! My OOP
style is... shall we say 'idiosyncratic'? And as a Lingo person I'm used to
doing things a bit back-to-front in any case (Director's inheritance model
is a little strange).
People can get a bit bogged down in 'correct' ideas about OOP, in my
opinion, with theoretical arguments about 'is-a' versus 'has-a' and so on.
But the basic principle of 'keep the information where it's useful' and
'remember who knows what when' is the key.
I did find the book 'surviving object-oriented projects' quite interesting,
although it's mostly aimed at large-scale projects with a large team, and
very data-driven.
Danny
_______________________________________________
[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