Variable Object Property Names in As3 flex?

I need to create variable object property names for use with the data grid component.

This works:

 data = new Object();
 data.some_name = "the data";

But this does not:

 data = new Object();
 colName = "some_name";
 data[colName] = "the data";

Can anyone help me? Can object property names be variable?

Answers


var colName:String = "Column Title";
var colNameNoSpace:String = "ColumnTitle"

var dataObject:Object = new Object();
dataObject[colName] = "What's the problem?";
dataObject[colNameNoSpace] = "There's no problem!"

trace(dataObject["Column Title"]);  //What's the problem?
trace(dataObject[colName]);         //What's the problem?
trace(dataObject.ColumnTitle);      //There's no problem!
trace(dataObject[colNameNoSpace]);  //There's no problem!

Need Your Help

What is the Dependency Inversion Principle and why is it important?

oop glossary principles

What is the Dependency Inversion Principle and why is it important?

Synchronize the PoolingClientConnectionManager or not

java android http singleton synchronize

In my app more than one IntentService connect/communicate with a Tomcat server at random intervals depending on user interaction with the application.