0

I have the following problem:

Description:

I have a page with a button and a spark list (spark.components.List), when the button is clicked, all the elements in the list should change their label.

The list uses a custom item renderer to display the data (The renderer is a spark item renderer: s:ItemRenderer and the data that will be displayed comes from database).

When I click the button, I dispatch an event "button_clicked", that event should be listened by all the elements in the custom item renderer.

In the renderer, I have this function that should listen to the "button_clicked" event:

public function init():void 
{
this.addEventListener("button_clicked", button_clicked);
}

public function button_clicked(event:Event):void 
{
mdm.Dialogs.prompt("Button clicked event dispatched");
}

Problem: The method "button_clicked" is never executed, which means that the event is not listened in the item renderer.

Anyone that can help me to understand how to dispatch an event in a parent and listen to it in the ItemRenderer object.

Thanks

Bakudan
  • 19,134
  • 9
  • 53
  • 73

1 Answers1

0

From a related question:

In renderer's init(), you need to add an event listener not to the renderer, but to the container which dispatches the event.

Example:

container.addEventListener(Container.SELECT_ALL_USERS, selectAllHandler, false, 0, true);
Community
  • 1
  • 1
Jason Towne
  • 8,014
  • 5
  • 54
  • 69