Skip to main content
Participant
April 23, 2006
Answered

Lisetening for Property change

  • April 23, 2006
  • 1 reply
  • 203 views
I have created a MC to be used as a button. It is generic and I customize it per instance. It contains an onRelease event handler.

I am confused as to what approach I can take within the MC's onRelease statement that would allow the parent to 1> know the MC has been clicked & 2> know which instance of the MC has been clicked (without putting onRelase code for each instance at the parent level).

I was trying the following...

myMC.onRelease = function() {
_parent.clickedButton = myMC._name;
};

...but I couldn't figure how to make the parent listen for a change to clickedButton.

How can I listent for a variable change? Is there a better approach?

thx,
Nathan
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer rapheld
Looks like I can answer my own question. In case anyone else is confused as to how to do this, I used the Object.watch method.

After doing the above in the MC, I included the following in the parent...
var btnWatcher:Function = function(prop, oldVal, newVal, userData) {
trace(newVal);
};

this.watch("clickedButton", btnWatcher);

1 reply

rapheldAuthorCorrect answer
Participant
April 23, 2006
Looks like I can answer my own question. In case anyone else is confused as to how to do this, I used the Object.watch method.

After doing the above in the MC, I included the following in the parent...
var btnWatcher:Function = function(prop, oldVal, newVal, userData) {
trace(newVal);
};

this.watch("clickedButton", btnWatcher);