SharedObject: Dynamically access data

Hello,

I would like to encapsulate access of a SharedObject in a class. In AS3 I could dynamically access data bits like so:

public function getValue(name : String, defaultValue : String = null) : String
{
    return sharedObject.data[name];
}

However the access with [name] does not seem to be possible in Haxe. The compiler says: Cookie.hx:99: characters 38-42 : String should be Int

How can I get a similar behavior in Haxe?

Thanks in advance,
Ruben

Try return Reflect.getProperty(sharedObject.data, name);

1 Like