Search code examples
apache-flexdynamicgenericsidentifier

generic identifier


as I probably do not describe the problem in the right terms, I was not able to get an answer with google. Please excuse!

In the following code, I would like to replace 'hardcoded' identifier COMMENT with the variable editedField. How to do that?

var editedField:String = event.dataField;
if (model.multipleProcessingData[i][editedInformationProductNO].COMMENT != null{
    ...
}

Solution

  • Make sure you wrap this in try/catch block for NPE's, as you'll eventually find one with this many [] accessors.

    A better, more OOP, would be to have an accessor function on your model that you can pass your data to: model.getEditedField(i, editedInformatioNProductNO, editedField)

    This will make it easier to troubleshoot and add good error messages to your app if things don't turn out like you expected.