Question about binding

I don’t understand the difference between @:bind and the usage of an object method like onClick. Where and when should I use bind, and why? Instead, when & why is better the second way?

Moreover, sometimes it seems that @:bind doesn’t work.
I created an app with some checkboxes. If I try to bind the mouse click event with bind to one of those ones with bind it seems that it doesn’t work, while if I use the onClick method, it does work:

// this one does NOT work
@:bind(checkUpper, MouseEvent.CLICK)
 function onCheckboxChange(e:MouseEvent) {
      trace("upper");
  }

// this one DOES work
 checkLower.onClick = function (e) {
     trace("lower");
 }

Normally they should be the same…

@:bind(checkUpper, MouseEvent.CLICK)
would do checkUpper.registerEvent(MouseEvent.CLICK, onCheckboxChange);

though I think with checkboxes it’s better to use UIEvent.CHANGE , that’s maybe the problem

(very) late to the party :confused:

But for completeness ill answer (super sorry for the crazy late upkeep of this forum!):

there is no functional difference here, both expand, effectively, into x.registerEvent(....)… Do you have a more full example?

As for “why” to use bind, its just a way to keep things neat, it just means you dont have to use “onClick” or “registerEvent” somewhere else in your code, the handler is “next” to the bind definition

Cheers,
Ian