Suggestion for event handlers...

Got a question? Need help? Post here!

Suggestion for event handlers...

Postby xxbbcc » Mon Aug 26, 2013 12:21 pm

I was trying to assign a common event handler to several AxButton objects when I realized that the callback function doesn't specify which button initiated the callback. This is fine if each button has a specific function assigned to it but I'm building the UI dynamically so I don't know exactly what buttons will be added - I have a common event handler for all buttons that figures out what to do based on properties of the button.

I suggest that all event handlers in Axel should have at least one parameter, the source of the event so that client code can know which object initiated the callback. I locally modified the AxButton.as file for this - it now works well with both statically and dynamically created buttons:

Code: Select all
override public function update():void {
   if (released()) {
      if (callback != null && onRelease) {
         callback(this);
      }
      labelOffset = 0;
   } else if (clicked()) {
      if (callback != null && !onRelease) {
         callback(this);
      }
      labelOffset = 1;
   }
    ...
xxbbcc
Sergeant
 
Posts: 20
Joined: Fri Jul 19, 2013 9:02 am

Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron