How to dispatch a triggered event from a custom item renderer (Starling version)
A custom item renderer should dispatch Event.TRIGGERED
when it is tapped or clicked, similar to a Button
.
Using the TapToTrigger
class, it's easy to dispatch Event.TRIGGERED
on tap or click:
public class CustomItemRenderer extends LayoutGroupListItemRenderer
{
public function CustomItemRenderer()
{
super();
this._trigger = new TapToTrigger(this);
}
private var _trigger:TapToTrigger;
}
That's it! The TouchEvent.TOUCH
listeners will be added automatically, and your item renderer will dispatch Event.TRIGGERED
like a button.
You should also learn how to use TapToSelect
to change isSelected
and dispatch Event.CHANGE
when tapped or clicked.