About LayoutManager and Updating the Display List

DUH! Hehe. Thanks for the comments and for clearing this one for me. That’s so obvious I don’t know how I missed it. Event.ADDED, Event.REMOVED and the event propagation mechanism takes care of this problem. Closing this one up.

One problem with updating the display list in Flash components is that you have no way of knowing exactly when it’s changed and needs to be updated without either user interaction (mouse events, for example) or testing it every frame (Event.ENTER_FRAME). There are no native Event.CHILD_ADDED or Event.CHILD_REMOVED events and the only DisplayObject that has dispatches Event.RESIZE is Stage. The one event that comes closer to that is Event.RENDER, but it cannot be trusted because it is asynchronous, meaning it can take a while to happen and the display list might be outdated a long time when it happens.

LayoutManager uses Event.ENTER_FRAME to update the layout and checks for changes in size every frame, what can be resource consuming. But so far, it seems like the only way to get around with it.


2 Responses to About LayoutManager and Updating the Display List

  1. Erick Wilder says:

    Rutkoski, a arquitetura de eventos do flash permite que sejam adicionados listeners aos objetos “pai”, que são notificados quando um evento occore em um objeto “filho”. Existe sim eventos que permitem saber “quando” algo foi adicionado ou removido de um objeto:
    Event.ADDED e Event.REMOVED. Quando você adiciona estes eventos a um objeto que deve receber/remover objetos do tipo DisplayObject, ele será notificado:

    var container:Sprite = new Sprite();
    container.addEventListener(Event.ADDED, _addedListener);
    function _addedListener(evt:Event):void
    trace(evt.currentTarget + ' recebeu um novo filho:' +evt.target);


  2. Sam says:


    I think you are wrong about missing the CHILD_ADDED event. Check this link:


    (Search for added:Event)


%d bloggers like this: