How to put event in dynamic creation on flex?

Please, help. I want to add a click event on a checkbox that I created dynamically so that I know which checkbox I click.

Here is my code in action script:

var myCheckbox: CheckBox = new CheckBox (); vbox.addChild (myCheckbox);

How to add click event on checkbox?

+3
source share
1 answer
private function myCheckboxClicked(event:MouseEvent)
{
    // doStuff();
}

...

myCheckbox.addEventListener(MouseEvent.CLICK, myCheckboxClicked); 

As long as it inherits from EventDispatcher, you can attach a listener and it will dispatch events as usual.

+4
source

Source: https://habr.com/ru/post/1703555/


All Articles