Andrew Thompson
Andrew Thompson

Reputation: 139

Shared Object Syntax

In AS3 I would like to set the key of a shared object with the contents of a string as opposed to specifically naming the key.

so.data.test = "andy"   // this is the basic working system 

I do not want to write test I want something like this

// this is a non working and incorrect solution but shows what I am trying to do.
String myKey = "test"
so.data.{myKey} = "andy" 

Is this an impossible ask?

Upvotes: 0

Views: 103

Answers (1)

shanethehat
shanethehat

Reputation: 15570

Untested, but you could try:

var myKey:String = "test";
so.data[myKey] = "andy";

Upvotes: 4

Related Questions