Announcement

Collapse
No announcement yet.

Loading a Map in ActionScript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Loading a Map in ActionScript

    Want to load an Unreal map straight from ActionScript? It's easy!
    1. Add a CLIK Scrolling List (or Drop Down Menu) to the stage, and give it an instance name of 'maplist'.
    2. Add a CLIK button to the stage, and give it an instance name of 'mapConfirmBtn'.
    3. Add a new layer and name it 'actions'.
    4. On the actions layer, enter this code:



    Code:
    import flash.external.ExternalInterface
    
    maplist.dataProvider = ["DM-Deck","VCTF-Necropolis"];
    var selectedMap:String;
    Next, for a Scrolling List, use:

    Code:
    maplist.addEventListener("itemPress", this, "HandleItemClick");
    OR - if you chose to use a drop down menu, use:

    Code:
    maplist.addEventListener("change", this, "HandleItemClick");
    Now, add an event listener for the button.

    Code:
    mapConfirmBtn.addEventListener("press", this, "LoadLevel");
    Then, create the map selection handler function:

    Code:
    function HandleItemClick(event:Object)
    {
        // use this code for a Scrolling List
        trace("Scrolling List Selection: " + event.item);
        selectedMap = event.item;
    
        // or use this code for a drop down
        trace("Drop Down Selection: " + event.data);
        selectedMap = event.data;
    }
    Finally, add the function that will tell Unreal to load the level.

    Code:
    function LoadLevel()
    { 
        var command:String = "open ";
        command += selectedMap;
        trace(command);
        ExternalInterface.call("ConsoleCommand", command);
    }
    Save & Publish.
    Import the SWF into UDK
    In Kismet, you'll need to use OpenGFxMovie to play this movie in your menu level on a player spawn event.
    Use your own custom menu class, or the standard GFxMoviePlayer class.

    #2
    Works wonderfully, Thanks so much for this tutorial. I definitely think this should be a sticky.

    Comment


      #3
      Wouldn't a simple fscommand be much easier?

      Comment


        #4
        fscommand is for testing

        Comment

        Working...
        X