UDN
Search public documentation:

GFxReturnFunctions
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > User Interfaces & HUDs > Scaleform GFx > How to get return values from ActionScript calls

How to get return values from ActionScript calls


Overview


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

Simple variables


First, our calling function:

Unrealscript
function GetRetValueOfASFunction()
{
  local string retVal;

  retVal = CallASFunction();

  `log("MyASFunction() Return Value: " @ retVal);
}

Next, our wrapped ActionScript function call:

Unrealscript
function string CallASFunction()
{
  return ActionScriptString("MyASFunction");
}

Finally, our ActionScript function:

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

  return retVal;
}

Arrays and Objects


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

Unrealscript
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
function MyASFunction():Array
{
  var retVal:Array = [{Name: "Testing", Type: "String"}, {Name: "Testing 2", Type: "Float"}];
    
  return retVal;
}