Jan Schluenzen wrote:
How do you guys handle the following situation:
I have a class, let's say Dog that holds an instance of the class Leg.
Outside of Dog I have another class called Street that holds the dog.
Anyway, now I want street to find out whenever the dog's leg has
moved. The only way I can figure out how to do that is to send the
"move" event of the Leg class first to the holder of the Leg object
(in this case Dog) and then on to the holder of Dog, in this case
Street. I've ran into more complex cases when I've had to hand down
events through several classes...
What about creation of "event forwarder" method? Something like
function forwardEvent(event:String, target:Object)
{
target[event]();
}
when you pass chain of objects to target. In this case you have to keep
object references chain but to my mind it's impossible to avoid using of
such a chains, method or references.
And then use accessors:
// Dog instance
move("move",
this.getStreet().getCity().getState().getCountry().getPlanet().getSolarSystem());
--
Michael Klishin
http://www.novemberain.com
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders