문제

I have the following issue related to how can i create an Object varible from a String name.

var obj_product:Object              = new Object;
obj_product.product                 = producto.nombre_producto;
obj_product.products_proveedorID    = product.ID;
obj_product.productID               = product.productID;
obj_product.price                   = 0;

if ( _extra_headers.length > 0 && _extra_headers[0].length > 0)
    for (var index:int=0; index < _extra_headers.length; index++ )
        obj_product._extra_headers[index] = 0;

_extra_headers is an Array where I hold new header names in the Datagrid, so for every new name I need to create its variable within the object.

Whats should I do?

도움이 되었습니까?

해결책

I'm not an ActionScript programmer, but on the assumption that it's close enough to JavaScript, replace the last line with this:

obj_product[_extra_headers[index]] = 0
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top