views:

897

answers:

3

I want to count (via google analytics) the times a pop-up is displayed to the user. Which event should I use to deduce that the pop-up is being displayed to the user?

A: 

From my own testing, it looks like using either would work. But it would be nice to know which is the more 'correct' one to use, and just what the difference is between the two.

Hisham
+5  A: 

If a new pop up is created every time you display one, it doesn't matter which one you use as both events will be fired upon creating. If you are reusing the same object, you should use addedToStage as creationComplete is dispatched only once per UIComponent.

  • creationComplete is dispatched when the component, and all of its child components, and all of their children, and so on have been created, laid out, and are visible.
  • addedToStage is dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained.

So if you are reusing the same object, you will get an addedToStage every time you display it.

Amarghosh
A: 

The first addedToStage event occurs before creationComplete so if you need to access child components you'll need to use both.

gharley