0 Replies Latest reply on Nov 17, 2012 7:32 PM by Purushotham Nayak

    Spark Containers elementAdd event and setElementIndex

    Purushotham Nayak

      I'm trying to write a listener that gets triggered when an element is added to a Spark Container. I just noticed that for a Spark Group container if I register a listener for the elementAdd/elementRemove events (ElementExistenceEvent.ELEMENT_ADD/ElementExistenceEvent.ELEMENT_REMOVE), the same event gets fired if I change the depth order of the elements in the Group using setElementIndex (E.g. to bring one component on top of the other). Is there a way to know when an element gets added for the first time (i.e. excluding the index re-ordering?). Per the documentation elementAdd should work for this.

      The documentation for elementAdd says.

      Dispatched when a visual element is added to the content holder. event.element is the visual element that was added.

      However this page says

      Spark containers dispatch multiple itemAdd and itemRemove events.

      I couldn't find itemAdd/itemRemove anywhere in the reference. The setElementIndex reference doesn't say anything about add/remove events getting fired.