Flag Capture Indicator

The flagMC symbol, located in the flag layer of Scene 1 of HUDKit.fla, is the container for the flag capture indicator. flagMC contains the flag symbol, which is divided into two parts, the flag capture indicator bitmap and the arrow indicator (arrow) which moves left and right based the CaptureState of the flag. The indicator fades-in when a player is near a capture objective and will fade-out when the player is no longer within range.

Figure 7: flagMC Symbol

The fade-in and fade-out animations for flagMC are done on the Flash timeline using a Classic Tween. flagMC’s timeline has 4 figurative states represented by 5 Keyframes: Hidden, Visible, Fade-In, and FadeOut. These states are visited using GotoAndStop() and the Keyframes’ labels/numbers (1, 5, “On”, “Off”, etc…).

FxHUDView::UpdateEvents(), copied below, controls flagMC’s states and updates arrow’s location using the simulation’s data.

// Flag capture indicators and reticule behavior.
void FxHUDView::UpdateEvents(FxHUDEnvironment *penv)
{
    Value::DisplayInfo info;

    if (penv->IsHUDPlayerCapturingObjective())
    {
        if(!bFlagMCVisible)
        {
            SetVisible(&FlagMC, true); // Set the Flag MovieClip's visibility to true.
            FlagMC.GotoAndPlay("on"); // Play the fade-in animation once.
            bFlagMCVisible = true;
        }

        // Shift the x-coordinate of the Flag Arrow to show the capture state   
        // of the flag the player is currently capturing.
        info.SetX(penv->GetHUDCaptureObjectiveState() * 177);
        FlagArrowMC.SetDisplayInfo(info);
        info.Clear();
    }
    else if (bFlagMCVisible & !penv->IsHUDPlayerCapturingObjective())
    {
        // If the flag indicator is still visible and the player is
        // no longer capturing an objective, play the fade-out animation
        FlagMC.GotoAndPlay("off");
        bFlagMCVisible = false;
    }
}

When flagMC.GotoAndPlay("on") is called, flagMC plays its fade-in animation and then stop in the Visible state. When flagMC.GotoAndPlay("off") is called, flagMC plays frames 11-20, a fade-out animation. When the animation reaches Frame 20, it will automatically restart playback from Frame 1. This is default Flash behavior; no extra ActionScript or C++ is necessary. Because Frame 1 contains a stop(); call, the MovieClip will stop after playing Frame 1. This is ideal, since the symbol is hidden in Frame 1 as its Alpha is set to 0.

The arrow is shifted horizontally using GFx::Value::SetDisplayInfo(). This method is passed a new GFx::Value::DisplayInfo with updated x-coordinate based on the CaptureState of the entity.