PDA

View Full Version : Getting variable information from external swf



TheAgent
12-09-2010, 07:18 PM
So in my buy menu i want to get a variable information from an external swf file, and im not sure how to go about that.

If anyone has any suggestions thanks a bunch!

Matt Doyle
12-10-2010, 10:02 AM
The ActionScript Variables



var MyString:String = "Something cool";
var MyNumber:Number = 37;
var MyBoolean:Boolean = true;


The UnrealScript


var bool myBoolean;
var string myString;
var float myNumber;

var GFxObject RootMC

RootMC = GetVariableObject("_root");

/* Get AS Vars */
myBoolean = RootMC.GetBool("MyBoolean");
myString = RootMC.GetString("MyString");
myNumber = RootMC.GetFloat("MyNumber");

`log("##### MyBoolean: "@myBoolean);
`log("##### MyString: "@myString);
`log("##### MyNumber: "@myNumber);

/* Set AS Vars */
RootMC.SetBool("MyBoolean", false);
RootMC.SetString("MyString", "Something AWESOME!");
RootMC.SetFloat("MyNumber", 100);

`log("##### MyString changed to: "@RootMC.GetString("MyString"));

TheAgent
12-10-2010, 01:32 PM
why thank YOU! : D

Kaldrick
02-11-2011, 03:32 AM
And if I have variables nested? Like, I've got a Number variable inside a button, inside a movieclip. How can I take this value? When I try to do something like that:

ButtonIndex = GetVariableObject("_root.container.Button1");
index = ButtonIndex.GetFloat("index");
`log(" My index: "@index);
My UDK crashes ;P
Error is:

Critical: appError called: Assertion failed: gresult.GetType() == GFxValue:UT_Number [File:c:\depot\UnrealEngine3\Development\Src\GFxUI\ Src\GFxUIMoe.cpp] [Line: 1183]

I've tried putting button inside _root, instead of nesting it, and I've got the same problem still. Anyone had a similiar problem?

Kaldrick
02-11-2011, 11:42 AM
I've found somewhere that those bugs are generally connected to typos in variable names. I've rechecked it few times and everything seems correct. Anyone got some advice?

Matt Doyle
02-11-2011, 12:51 PM
You code looks correct. Are you sure there is an AS Number type variable called 'index' that lives inside Button1's timeline, which is inside the instance container, which is on the _root?

And I assume you've declared ButtonIndex as a float?

Kaldrick
02-11-2011, 02:02 PM
Yup, ButtonIndex is a local float inside a function, that is running on mouseover event, called from AS. And index is a :Number variable. I tried to put it in several places and failed miserably every time. Even though I 'hacked it', and just made several functions instead of dynamic one, I'd still like to know the answer.

Matt Doyle
02-11-2011, 02:34 PM
That could be it. Being a local variable means index is accessible only by that function. Nothing else can see it.

Kaldrick
02-11-2011, 02:36 PM
But GFx Object, from which I take this variable, is local too, in the same function. And I've tried to make it a global variable, and it still got me nothing.
Mind you, I've got 2 gfxobjects where I set (instead of getting) a string Text value in the same function, and they work just fine.

Matt Doyle
02-11-2011, 03:19 PM
Can you post your AS function?

Kaldrick
02-11-2011, 03:51 PM
On container layer, with container movie_clip

import flash.external.ExternalInterface;
Button1.onRollOver = function()
{
ExternalInterface.call("ShowItemNameDesc1");
}
And there is a button, no matter where I put it, is it container movie clip, or layer, or another layer in _root.


var index:Number = 0;

Matt Doyle
02-11-2011, 03:55 PM
Well, according to your code, the var "index" is inside Button1.

ButtonIndex = GetVariableObject("_root.container.Button1");
index = ButtonIndex.GetFloat("index");

But, if its a standard Flash button, you can't even do this.

Is it a CLIK widget or a Flash button symbol? What I need to know is...

where is this line of code physically at?

var index:Number = 0;

It doesn't matter what layer it's on. I need to know what symbol it is inside.

Kaldrick
02-12-2011, 02:48 AM
It's a Flash button symbol. Didn't knew I can't do this with it ;] How should I do it then?

Matt Doyle
02-14-2011, 11:01 AM
Well, to be honest I don't know. It all depends on what exactly you are trying to do. If you can tell me what you're trying to do, then I can tell you what the best approach would be.