cannot access actionscript variables

#1
hello, i'm having trouble accessing actionscript variables in my code.
Here are the variables i want to access. I had also tried using variables, but to no avail.
Image
Here is how they are implemented in my xml file:
Image
And here is how i am trying to access them in my code:
Image

I had followed the instructions in the cryengine documentation and tried to look for solution online, but i couldn't find anything.

Re: cannot access actionscript variables

#5
Can you tell us if you are using Flash CS6 or a mix of Vectorian Giotto and Flash Develop?
For Variables, if you are not using Flow Graph/Schematyc to access the variables, you do not need to specify them in the XML like the functions and events.

As mentioned though, make sure that what you want to access are not inside a class (variable or function), and are on the first frame in the flash scene.
Uniflare
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Re: cannot access actionscript variables

#6
Can you tell us if you are using Flash CS6 or a mix of Vectorian Giotto and Flash Develop?
For Variables, if you are not using Flow Graph/Schematyc to access the variables, you do not need to specify them in the XML like the functions and events.

As mentioned though, make sure that what you want to access are not inside a class (variable or function), and are on the first frame in the flash scene.
Ok, I'm using a mix of Vectorian Giotto and FlashDevelop.

Would i have to define the variables in a separate file or in another external class?
I have tried another class, but it didn't seem to make any difference, but i'm gonna try to see if what i am calling in my c++ code is wrong.

Re: cannot access actionscript variables

#7
The c++ Code seems to be correct. Your ActionScript though needs some tweaking ;).

References to variables and functions are relative to the global _root object. In Flash Develop we don't write code the same way we do in Flash Native as we need to load classes (instead of embedding code in the frames).
For this reason, you need to explicitly declare variables on the _root object to be accessed.

Here is an example:


TestClass.as (FlashDevelop)

Code: Select all

/**
* ...
* @author cryflare
*/
class TestClass
{
// Static variables should be initialized as soon as the scene loads. This will call the main function below.
static var Test:TestClass;

// When the test class instance is created, we can set a new function on the _root object.
public function TestClass()
{
_root.txtMyText.htmlText = "Loaded.";

_root.MyFunction = function(str: String):Void {
_root.txtMyText.htmlText = str;
}
}

// When main is called, we create a new instance of the test class
public static function main(mc:MovieClip):Void {
Test = new TestClass();
}
}

test1.xml (libs/ui/uielements)

Code: Select all

<UIElements name="TestUI">

<UIElement name="test_VGFD_UI">

<GFx file="ui_test_1_injected.gfx" layer="0">
<Constraints>
<Align mode="dynamic" valign="center" halign="center" scale="1" max="1" />
</Constraints>
</GFx>

<functions>
<function name="MyTestFunc" funcname="MyFunction">
<param name="String" desc="" type="String"/>
</function>
</functions>

</UIElement>

</UIElements>

Assuming the GFX file is created successfully (In my case, in Vectorian Giotto I simply made a dynamic text element named "txtMyText") you should be good to go.
This should work the same for variables, they need to be assigned relative to the _root object. You should then even be able to index them.

Tip*: Test the Flash Element/function/variable exposure etc via Flow Graph.

Let us know if this helps.
Uniflare
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Re: cannot access actionscript variables

#8
The c++ Code seems to be correct. Your ActionScript though needs some tweaking ;).

References to variables and functions are relative to the global _root object. In Flash Develop we don't write code the same way we do in Flash Native as we need to load classes (instead of embedding code in the frames).
For this reason, you need to explicitly declare variables on the _root object to be accessed.

Here is an example:


TestClass.as (FlashDevelop)

Code: Select all

/**
* ...
* @author cryflare
*/
class TestClass
{
// Static variables should be initialized as soon as the scene loads. This will call the main function below.
static var Test:TestClass;

// When the test class instance is created, we can set a new function on the _root object.
public function TestClass()
{
_root.txtMyText.htmlText = "Loaded.";

_root.MyFunction = function(str: String):Void {
_root.txtMyText.htmlText = str;
}
}

// When main is called, we create a new instance of the test class
public static function main(mc:MovieClip):Void {
Test = new TestClass();
}
}

test1.xml (libs/ui/uielements)

Code: Select all

<UIElements name="TestUI">

<UIElement name="test_VGFD_UI">

<GFx file="ui_test_1_injected.gfx" layer="0">
<Constraints>
<Align mode="dynamic" valign="center" halign="center" scale="1" max="1" />
</Constraints>
</GFx>

<functions>
<function name="MyTestFunc" funcname="MyFunction">
<param name="String" desc="" type="String"/>
</function>
</functions>

</UIElement>

</UIElements>

Assuming the GFX file is created successfully (In my case, in Vectorian Giotto I simply made a dynamic text element named "txtMyText") you should be good to go.
This should work the same for variables, they need to be assigned relative to the _root object. You should then even be able to index them.

Tip*: Test the Flash Element/function/variable exposure etc via Flow Graph.

Let us know if this helps.
Thanks!
This makes things clearer. I've been trying a different way now which works in they way that i had wanted it to. Thanks for the advice. :D

Who is online

Users browsing this forum: No registered users and 1 guest