jeudi 16 février 2017

Object name from variable in Actionscript

I am trying to use the string in a variable to create an item in an object.

Example non functioning code:

    private var myName:String = 'group1';

    private var _ins:Object = {
        myName : { 
            data1: arr[0],
            data2: arr[1]               
        }
    }

I can not understand what syntax to use to make myName be 'group1' text. Currently I am using:

    private var _ins:Object = {
        'group1' : { 
            data1: arr[0],
            data2: arr[1]               
        }
    }

Aucun commentaire:

Enregistrer un commentaire