This short tutorial provides two methods to explains how to easily get the original dimensions (width and height) of your SWF file in UnrealScript. The dimensions are found in the Document Settings of your FLA file. The tutorial assumes you have a HUD wrapper class which instantiates your HUD.
Method 1
First, your HUD Flash file should have the following ActionScript on Frame 1:
ActionScript 2.0
Then, in your UnrealScript HUD Wrapper (NOTE: The code related to this tutorial is in red):Code:_global.gfxExtensions = true; var MovieWidth:Number = Stage["originalRect"].width; var MovieHeight:Number = Stage["originalRect"].height;
UnrealScript
Method 2Code:class SFHudWrapper extends UTHUDBase; var SFHud HudMovie; var class<SFHud> HudClass; var vector2D HudMovieSize; simulated function PostBeginPlay() { Super.PostBeginPlay(); CreateHUDMovie(); HudMovieSize = GetMovieSize(HudMovie); `log("Movie Dimensions: " @ int(HudMovieSize.X) @ "x" @ int(HudMovieSize.Y)); } function CreateHUDMovie() { HudMovie = new HudClass; HudMovie.SetTimingMode(TM_Real); HudMovie.Init(class'Engine'.static.GetEngine().GamePlayers[HudMovie.LocalPlayerOwnerIndex]); HudMovie.SetViewScaleMode(SM_NoScale); // SWF will be drawn at original dimensions regardless of Unreal client resolution HudMovie.SetAlignment(Align_TopLeft); // SWF's top left corner at top left corner of Unreal client window. } function vector2D GetMovieSize(GFxMoviePlayer Movie) { local vector2D MovieSize; MovieSize.X = Movie.GetVariableNumber("_root.MovieWidth"); MovieSize.Y = Movie.GetVariableNumber("_root.MovieHeight"); return MovieSize; } defaultproperties { HudClass = class'SFHud' }
No ActionScript required.
UnrealScript
Code:var GFxObject HudMovieSize; simulated function PostBeginPlay() { Super.PostBeginPlay(); CreateHUDMovie(); HudMovieSize = HudMovie.GetVariableObject("Stage.originalRect"); `log("Movie Dimensions: " @ int(HudMovieSize.GetFloat("width")) @ "x" @ int(HudMovieSize.GetFloat("height"))); }



Reply With Quote




Bookmarks