UDN
Search public documentation:

GFxReturnFunctionsCH
English Translation
日本語訳
한국어

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 主页 > 用户界面 & HUD > Scaleform GFx > 怎样从ActionScript调用中获得返回数值

怎样从ActionScript调用中获得返回数值


概述


这个简短的教程指导您在从UnrealScript(虚幻脚本)中调用一个ActionScript时怎样取得一个返回值。

简单的变量


首先,我们调用函数:

Unrealscript
function GetRetValueOfASFunction()
{
  local string retVal;

  retVal = CallASFunction();

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

接下来,我们封装ActionScript(动作脚本)函数调用:

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

最后,以下是我们ActionScript(动作脚本)函数:

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

  return retVal;
}

数组和对象


要取得稍复杂内容的返回数值,如一个数组,类似这样的情况可以这么做:

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;
}