PDA

View Full Version : [AS3] Broadcast event to all cells of a TileList


rocker
06-17-2009, 03:33 AM
I have a TileList component with a custom cellrenderer in my movie. I want to broadcast an event to all the cells of the tile (say an "update" event that makes all the cells update their data in some way).

Is there a way to do so?

rocker
06-17-2009, 06:55 PM
Anything, anyone? Is there any way to pass events to the cells of a tilelist or datagrid?

rocker
06-18-2009, 07:00 PM
I figured out a way myself. It is a kind of round about way of 'broadcasting' the event, but serves my purpose well. For anyone interested, here is the solution.

AS3 does not allow sending events from parents to children. So instead of sending the event from the parent (the movie containing the TileList) to its children (TileList cells), I do this in the tilelist code:

this.parent.addEventListener(MyCustomEvent.EVENT, ....);

Whenever the parent receives MyCustomEvent.EVENT, all cells of the TileList receive it at once! Neat, isn't it? :)