E
E
Eugene2016-03-31 11:32:57
ActionScript
Eugene, 2016-03-31 11:32:57

How to dynamically access a class field from another namespace?

How can I dynamically refer to a class field from another namespace?

public namespace myNamespace = "http://mydomain.com/mypackage/";

...

public var _publicVar: String = "foo";
myNamespace var  _namespaceVar: String = "bar";

...

trace(this["_publicVar"]);
trace(this["_namespaceVar"]); // <<< ????

Through describeType, these variables are available, which means they can be accessed
<variable name="_namespaceVar" type="String" uri="http://mydomain.com/mypackage/">
....
</variable>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2016-04-01
@Onni

As I was told, you need to include the namespace:

use namespace myNamespace;
trace(this["_namespaceVar"]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question