Pop-ups and Notifcations

The popup symbol, located in the popup layer of Scene 1 of HUDKit.fla, is an animated event indicator. In this demo, popup is played whenever the user player reaches 3 or more consecutive kills (a kill streak). It will fade-in and play an animation when displayed and it will fade out after 3-5 seconds based on the C++ call.

Figure 12: popup Symbol

Popup is the core container for the pop-up. All of the animation for its sub-elements is done on popup’s timeline using Classic Tweens. popup contains 4 layers, actions, popupNumber, popupText and popupBG. popupBG is the animated black shape that “explodes” behind the number. popupText and popupNumber contain the textField symbols that display the text and number for the pop-up message. This symbol hierarchy is necessary to animate the textFields on the timeline.

The symbol has a “on” Keyframe, which can be called using GotoAndPlay() to start the animation. Once the initial animation is complete, the pop-up will fade out and playback will return to Frame 1 where it will stop, hidden with its Alpha set to 0.

// If a KillStreak event is fired, display the kill streak pop-up.
case FxHUDEvent::EVT_KillStreak:
{
    FxHUDKillStreakEvent* peventKS = (FxHUDKillStreakEvent*)pevent;

    // Format the number of kills
    String text;
    Format(text, "{0}", peventKS->GetSrcKillStreak());      
    PTextFieldMC.SetText(text); // Set the text field of the PopUp.

    // Play the fade-in animation, it will fade on its own after ~4 sec.
    PopupMC.GotoAndPlay("on");
}
break;

Here, the FxHUDEvent is cast as a KillStreak event. The number of consecutive kills is then retrieved from the player and formatted appropriately. The text for the pre-cached popupText’s textField symbol, PTextFieldMC, is set via C++ and GotoAndPlay(“on”) is used to trigger popup’s display animation.