In Flex, what's the difference between 'creationComplete' and 'addedToStage'?

I want to count (through google analytics) the time when a popup is displayed to the user. What event should I use to show that the popup is displayed to the user?

+6
flex google-analytics
source share
4 answers

If a new pop-up window is created at each display, it does not matter which one you use, since both events will be fired upon creation. If you reuse the same object, you should use addedToStage , since creationComplete dispatched only once per UIComponent .

  • creationComplete dispatched when a component and all its child components and all their children, etc. were created, laid out and visible.
  • addedToStage dispatched when a display object is added to the scene display list, either directly or by adding an auxiliary tree that contains the display object.

Therefore, if you reuse the same object, you will get addedToStage every time you show it.

+9
source share

Someone commented that you do not need to use both addToStage and createComplete (I needed 50 respondents to respond by making a new entry)

There seems to be a case where you need to use both. For example, when you need to update something every time a view is viewed, and the view is displayed when the state changes. When you first view the view, the creationComplete event occurs. Using addToStage at this point runs the risk that the child component will be empty. Several times when a view is displayed, it does not send creationComplete, just added ToStage

0
source share

From my own testing, it seems that using either will work. But it would be nice to know which one is the "right" to use, and what is the difference between them.

-one
source share

The first addedToStage event occurs before createComplete , so if you need to access the child components, you will need to use both.

-one
source share

All Articles