Ok! I have a flashVar variable that is coming into Flash, its URL encoded but I have already decoded it. My problem is I want the set of variables to be pushed into an array.
Let’s say the variables are
“&text0=Enter Text…&size0=18&font0=Arial&color0=0&rotation0=0&y0=360&x0=640&text1=Enter
Text…&size1=18&font1=Arial&color1=0&rotation1=0&y1=360&x1=640”
and so on…
What I want is the variables to go into an array like
myArray[0].text = Enter Text...
myArray[0].size = 18]
myArray[0].font = Arial
myArray[0].color = 0
myArray[0].rotation = 0
myArray[0].y = 360
myArray[0].x = 640
myArray[1].text = ...........
.............................
.............................
myArray[n].text = ...........
I think there must be some way to do this. Most probably I’m thinking regular expression, but I’m pretty bad at regular expression. Please some help would be very very appreciated.
Thank You!
You don’t have to decode your query string, just use the URLVariables object – it will do all the decoding for you. Then iterate over its dynamic properties to create your array. Use a RegExp to find the index numbers at the end of your variable keys:
Since your query string starts with a an ampersand, you might have to use
parseURLVariables ( myString.substr(1)), otherwise the URLVariables object will throw an error, complaining that the query string is not valid (it has to be url encoded, and start with a variable key).