Well, there are several ways to achieve your goal but I think that the
best and most elegant solution is creating a class for your buttons
which implements an event dispatching mechanism (e.g. Macromedia's
EventDispatcher) and dispatches a click event when the button was
pressed by the user. In your Question class simply add listeners to
the click events of the button instances (and use a delegation
implementation, e.g. mx.utils.Delegate).

  Attila

AS> (Putting aside whether or not this is best practice design, as I'm just
AS> trying to get my head around this.)
AS> 
AS> I've put three buttons in _root.questionInterface called button_1, 
AS> button_2, etc.  Elsewhere I have defined a class Question.  When an 
AS> instance of Question is displayed, it needs to modify the onRelease of 
AS> the three buttons so that the Question gets notified when each button 
AS> gets released.
AS> 
AS> Within the "Display" method of the Question, I want to do something like
AS> 
AS> for (var aNum=1; aNum<=5; aNum++) {
AS> 
AS>     var answerButton = _root.questionInterface["button_"+aNum];
AS>     // pseudo code:
AS>     make the onRelease of answerButton make a call to the function 
AS> AnswerSelected(aNum) inside of this
AS>     //
AS> 
AS>     // I have tried the following, but it's not right
AS>     answerButton.onRelease = function() { this.GiveAnswer(aNum);};
AS> 
AS>     
AS> }
AS> 
AS> 
AS> Any help greatly appreciated.  Thanks!


_______________________________________________
[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