UDN
Search public documentation:

GFxObjectArrayKR
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 에 전하는 법


문서 변경내역: James Tan 작성. 홍성진 번역.

개요


오브젝트 배열을 UnrealScript 와 ActionScript 사이로 전하는 법을 보여주는 간단 안내서입니다.

Unrealscript 에서 ActionScript 로


UnrealScript
/** Item 구조체 */
struct Items
{
  var string ItemName;
  var string ItemType;
  var string ItemDesc;
};

var array<Items> Inventory;

function SetUpInventory()
{
  local byte i;
  local GFxObject DataProvider;
  local GFxObject TempObj;
  local GFxObject RootMC;

  RootMC = GetVariableObject("_root");

  DataProvider = CreateArray();

  for (i = 0; i < Inventory.Length; i++)
  {
    TempObj = CreateObject("Object");
    TempObj.SetString("ItemName", Inventory[i].ItemName);
    TempObj.SetString("ItemType", Inventory[i].ItemType);
    TempObj.SetString("ItemDesc", Inventory[i].ItemDesc);
    DataProvider.SetElementObject(i, TempObj);
  }

  RootMC.SetObject("inventory", DataProvider);
  ShowInventory();
}

function ShowInventory()
{
  ActionScriptVoid("showInventory");
}

ActionScript
var inventory:Array = [];

function showInventory()
{
  for (i:Number = 0; i < inventory.length; i++)
  {
    trace("Name: " + inventory[i].ItemName + " | Type: " + inventory[i].ItemType + " | Description: " + inventory[i].ItemDesc);
  }
}

ActionScript 에서 Unrealscript 로


UnrealScript
function ListInventory()
{
  local GFxObject Item;

  // 메서드 1
  // 이 부분은 Flash 파일의 inventory[] 배열 0 요소에 보관된 인벤토리 아이템의 이름, 유형, 설명을 반환합니다.
  `log("Item Name: " @ RootMC.GetObject("inventory").GetElementMemberString(0, "ItemName"));
  `log("Item Type: " @ RootMC.GetObject("inventory").GetElementMemberString(0, "ItemType"));
  `log("Item Description: " @ RootMC.GetObject("inventory").GetElementMemberString(0, "ItemDesc"));

  // 메서드 2
  // 우선 inventory[] 배열 0 요소에서 찾은 GFxObject{} 로의 리퍼런스를 캐시하는 버전입니다.
  Item = RootMC.GetObject("inventory").GetElementObject(0);

  `log("Item Name: " @ Item.GetString("ItemName"));
  `log("Item Type: " @ Item.GetString("ItemType"));
  `log("Item Description: " @ Item.GetString("ItemDesc"));
}