The only time I really use watch is when extending the MovieClip class and have
a need to know when a built-in property changes,
like MovieClip.enabled
class Comp extends MovieClip {
private var __enabled:Boolean = true;
function Comp {
watch("enabled", setEnabled);
}
I like to think of the watch like a filter. I first started using watch
because you can get immediate notification of a change and then run an event
because of that change. But because you have to return the value in order
for it to get set, it makes more sense to use a getter/setter if you want to
I have used watch in the past to check for when a Boolean swaps between true
and false and use that to trigger functions to make things
visible/invisible. It allowed for a way to link a variable that changes
(Number, Boolean, String) to a function without implementing a full
listener.
On 8/11/07,
3 matches
Mail list logo