I have the following problem in AS3. I have a string like this one: “prop1:val1,prop2:val2,…”; I want to split and parse the string to obtain a dynamic object like this one: {prop1:”val1″, prop2:”val2″}.
The simple way to solve it is to cycle through the string values and to do:
if (strProp1 == “prop1”) o.prop1 = strVal1;
if (strProp1 == “prop2”) o.prop1 = strVal2;
Since I know the property names I expect, this works for me, but doesn’t seem to be an elegant solution. I’m wondering if there is another way in as3 (similar to the reflection api in java), to solve this.
A quick example using split , a new Object :