Marc Hughes


Home
Blog
Twitter
LinkedIn
GitHub
about
I am a developer from a bit west of Boston.

Flex ADDED_TO_STAGE event and scrollbars

15 Jan 2009

Be careful with ADDEDTOSTAGE 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 ADDEDTOSTAGE 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 ADDEDTOSTAGE events to fire and caused my bug.