This page contains the scripts for the video tutorial series for a Scaleform HUD.

I have added comment lines in to explain what the different parts do. Feel free to remove them.

I have also modified them a little from the video to get rid of the unecessary stuff

STGameInfo.uc

class STGameInfo extends UTDeathmatch;

DefaultProperties
{
 //Indentify your GameInfo
 Acronym="ST"

 //The class for your playerController (created later)
 PlayerControllerClass=class'ScaleformTutorial.STPlayerController'

 //The class for your GFx HUD Wrapper (created later)
 HUDType=class'ScaleformTutorial.STHUD'

 //This variable was created by Epic Games to allow back compatability with UIScenes
 bUseClassicHUD=true

 //Required values
 bDelayedStart=false
 bRestartLevel=false
 Name="Default__STGameInfo"
}

STPlayerController.uc

class STPlayerController extends UTPlayerController;

DefaultProperties
{
 bForceBehindView=false

 Name="Default__STPlayerController"
}

STHUD.uc

class STHUD extends UTHUDBase;

//Reference the actual SWF container (STGFxHUD created later)
var STGFxHUD HudMovie;

//Called when this is destroyed
singular event Destroyed() {
 if (HudMovie != none) {
 //Get rid of the memory usage of HudMovie
 HudMovie.Close(true);
 HudMovie = none;
 }

 super.Destroy();
}

//Called after game loaded - initialise things
simulated function PostBeginPlay() {
 super.PostBeginPlay();

 //Create a STGFxHUD for HudMovie
 HudMovie = new class'STGFxHUD';
 //Set the HudMovie's PlayerOwner
 HudMovie.PlayerOwner = PlayerOwner;
 //Set the timing mode to TM_Real - otherwide things get paused in menus
 HudMovie.SetTimingMode(TM_Real);
 //Call HudMovie's Initialise function
 HudMovie.Init(HudMovie.PlayerOwner);
}

//Called every tick the HUD should be updated
event PostRender() {
 HudMovie.TickHUD();
}

DefaultProperties
{
}

STGFxHUD.uc

class STGFxHUD extends GFxMoviePlayer;

//Create a Health Cache variable
var float LastHealthpc;

//Create variables to hold references to the Flash MovieClips and Text Fields that will be modified
var GFxObject HealthMC, HealthBarMC;
var GFxObject HealthTF;

//  Function to round a float value to an int
function int roundNum(float NumIn) {
 local int iNum;
 local float fNum;

 fNum = NumIn;
 iNum = int(fNum);
 fNum -= iNum;
 if (fNum >= 0.5f) {
 return (iNum + 1);
 }
 else {
 return iNum;
 }
}

//  Function to return a percentage from a value and a maximum
function int getpc(int val, int max) {
 return roundNum((float(val) / float(max)) * 100.0f);
}

//Called from STHUD'd PostBeginPlay()
function Init(PlayerController PC) {
 //Start and load the SWF Movie
 Start();
 Advance(0.f);

 //Set the cahce value so that it will get updated on the first Tick
 LastHealthpc = -1337;

 //Load the references with pointers to the movieClips and text fields in the .swf
 HealthMC = GetVariableObject("_root.healthbar_mc");
 HealthBarMC = GetVariableObject("_root.healthbar_mc.bar_mc");
 HealthTF = GetVariableObject("_root.healthbar_mc.health_txt");
}

//Called every update Tick
function TickHUD() {
 local UTPawn UTP;

 //We need to talk to the Pawn, so create a reference and check the Pawn exists
 UTP = UTPawn(PlayerOwner.Pawn);
 if (UTP == None) {
 return;
 }

 //If the cached value for Health percentage isn't equal to the current...
 if (LastHealthpc != getpc(UTP.Health, UTP.HealthMax)) {
 //...Make it so...
 LastHealthpc = getpc(UTP.Health, UTP.HealthMax);
 //...Update the bar's xscale (but don't let it go over 100)...
 HealthBarMC.SetFloat("_xscale", (LastHealthpc > 100) ? 100.0f : LastHealthpc);
 //...and update the text field
 HealthTF.SetString("text", round(LastHealthpc)$"%");
 }
}

DefaultProperties
{
 //this is the HUD. If the HUD is off, then this should be off
 bDisplayWithHudOff=false
 //The path to the swf asset we will create later
 MovieInfo=SwfMovie'STAssets.HUD.HudSwf'
 //Just put it in...
 bGammaCorrection = false
}

Actionscript Layer – Frame 1

import gfx.motion.Tween;
_global.gfxExtensions = true;

var angle:Number;

function init() {
 healthbar_mc._yrotation = -30;
 angle = 0;
}

init();

_root.onEnterFrame = function() {
 angle += 0.1;
 var sined:Number = Math.sin(angle) + 2;
 sined /= 2;

 healthbar_mc.bar_mc._z = -600 * sined;
 healthbar_mc.health_txt._z = -400 * sined;
}