Announcement

Collapse
No announcement yet.

Getting Return Values from ActionScript Calls

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

    Getting Return Values from ActionScript Calls

    Just a short and simple tutorial today on how to get a return value when calling an ActionScript function from UnrealScript.

    First, our calling function:

    Code:
    function GetRetValueOfASFunction()
    {
        local string retVal;
    
        retVal = CallASFunction();
    
        `log("MyASFunction() Return Value: " @ retVal);
    }
    Next, our wrapped ActionScript function call:

    Code:
    function string CallASFunction()
    {
        return ActionScriptString("MyASFunction");
    }
    Finally, our ActionScript function:

    Code:
    function MyASFunction():String
    {
        var retVal:String = "This text is being returned from a Flash function called by UnrealScript.";
    
        return retVal;
    }

    Arrays & Objects


    For retrieving the return value of something more complex, like an array, something like this would work:

    Code:
    function GetRetValueOfASFunction()
    {
        local array<GFxObject> retVal;	
    	
        retVal = CallASFunction();
        
        `log("MyASFunction() Array Element 0 Return Value: " @ retVal[0].GetString("Name") @ " | " @ retVal[0].GetString("Type"));
        `log("MyASFunction() Array Element 1 Return Value: " @ retVal[1].GetString("Name") @ " | " @ retVal[1].GetString("Type"));
    }
    
    function array<GFxObject> CallASFunction()
    {
        return RootMC.ActionScriptArray("MyASFunction");
    }

    ActionScript 2.0


    Code:
    function MyASFunction():Array
    {
        var retVal:Array = [{Name: "Testing", Type: "String"},
    	                {Name: "Testing 2", Type: "Float"}];
        
        return retVal;
    }

    #2
    Good tutorial.

    In my guess, it can solve my wonder.

    http://forums.epicgames.com/threads/830280-How-to-get-parameter-of-dispatchEvent()-in-unreal-script


    Thanks.

    Comment

    Working...
    X