AS3 Add Event Listener in For Each
- by Vinzcent
Hi,
I would like to add an eventlistener to all the elements I create in a for each loop.
But apperently the eventlistener only works with the latest created element.
How do I add an Event Listener to every element created in the for each loop?
This is my code:
for each(var showCase:ShowCaseItem in _bllShowCase.arrShowCase)
{
var listItem:ListItemShowCase = new ListItemShowCase(showCase);
listItem.y = yPos;
listItem.addEventListener("ITEMDELETED", refreshShowCaseItems);
this.addChild(listItem);
yPos += 20;
}
I hope you understand my question.
Thanks, Vincent