Flex ADDED_TO_STAGE event and scrollbars

Be careful with ADDED_TO_STAGE event handlers, I ran into a interesting bug today.  Upon resizing the browser window, the current “activity” the user was working on would restart.  It should only have restarted when it was added to the stage and was confusing me why it would occur upon resizing a browser window.

A little digging, and I figured out why.

If you have a component inside a flex container like a Canvas.  And the container is resized and all of a sudden it requires a scrollbar to fit everything you will get an extra ADDED_TO_STAGE event.  Internally the container removes the component, creates a content pane to scroll around, and moves all of it’s children from the base container object onto this content pane.  That removal/addition causes the ADDED_TO_STAGE events to fire and caused my bug.

0 Responses to “Flex ADDED_TO_STAGE event and scrollbars”


Comments are currently closed.