Results 1 to 5 of 5
  1. #1

    Lightbulb Getting The Original SWF Dimensions In UnrealScript

    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

    Code:
    _global.gfxExtensions = true;
    
    var MovieWidth:Number = Stage["originalRect"].width;
    var MovieHeight:Number = Stage["originalRect"].height;
    Then, in your UnrealScript HUD Wrapper (NOTE: The code related to this tutorial is in red):

    UnrealScript

    Code:
    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'
    }
    Method 2

    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")));
    }
    Last edited by Matt Doyle; 03-31-2011 at 03:40 PM.

  2. #2
    Palace Guard
    Join Date
    Aug 2008
    Location
    Location,Location
    Posts
    3,719

    Default

    Very nice, will this in turn be used to scale the SWF to fit any screen resolution?

  3. #3

    Default

    For details on how to do that, see this post:

    http://forums.epicgames.com/showthread.php?t=759121

  4. #4
    Palace Guard
    Join Date
    Aug 2008
    Location
    Location,Location
    Posts
    3,719

    Default

    Oh i see i might of mixed the two, well what would be the practical uses of getting the dimensions of your SWF movie?

    Thanks for the link :P


    Edit : Thanks for letting me know vv
    Last edited by TheAgent; 03-14-2011 at 02:36 PM.

  5. #5

    Default

    You may need to know the size of your SWF for mouse coordinate functions. Such as in the discussion found here: http://forums.epicgames.com/showthread.php?t=751705


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.