Loading variables in a loop

Hi!\r\rI’ve a .txt-file containing variables. The variables are structured like this:\r\raaa_301, bbb_301, ccc_301\raaa_302, bbb_302, ccc_302\r…\raaa_325, bbb_325, ccc_325\r\rTo use them in Flash I have to read them from the .txt-file and assign them. This could look like this:\r\ronClipEvent (data) {\r&nbsp &nbsp &nbsp &nbsp _root.aaa_301 = aaa_301;\r&nbsp &nbsp &nbsp &nbsp _root.bbb_301 = bbb_301;\r&nbsp &nbsp &nbsp &nbsp _root.ccc_301 = ccc_301;\r&nbsp &nbsp &nbsp &nbsp _root.aaa_302 = aaa_302;\r&nbsp &nbsp &nbsp &nbsp _root.bbb_302 = bbb_302;\r&nbsp &nbsp &nbsp &nbsp _root.ccc_302 = ccc_302;\r&nbsp &nbsp &nbsp &nbsp …\r&nbsp &nbsp &nbsp &nbsp _root.aaa_325 = aaa_325;\r&nbsp &nbsp &nbsp &nbsp _root.bbb_325 = bbb_325;\r&nbsp &nbsp &nbsp &nbsp _root.ccc_325 = ccc_325;\r}\r\rIs it possible to use a loop instead of write 301, 302, …325?\r\rI thought of:\r\ronClipEvent (data) {\r for (i=301; i=325; i++){\r&nbsp &nbsp &nbsp &nbsp _root.aaa_i = aaa_i;\r&nbsp &nbsp &nbsp &nbsp _root.bbb_i = bbb_i;\r&nbsp &nbsp &nbsp &nbsp _root.ccc_i = ccc_i;\r }\r}\r\rAny idea how the code could look like?\r\rMany thanks,\r\rHartwig

Are you sure that you’re txt is writen correctly?\r\rIt should look something like\r\r&aaa_301=something&bbb_301=something&ccc_301=something&aaa_302=something&bbb_302=something&ccc_302=something&

Hi!\r\rYes of course. The .txt-file is written correctly. I just wanted to demonstrate the structure of the variables. But how could the for-loop look like?\r\rHartwig

i think that code looks right…maybe create 3 for loops one for aaa, one for bbb, and one for ccc?

No no no no.

 onClipEvent (data) {\r\rfor (i=301; i=325; i++){\r\r        root["aaa_"+i] = this["aaa_"+i] ; // no _ in front of root.\r\r        root["bbb_"+i] = this["bbb_"+i] ;\r\r        }\r\r}

But I don’t see why you need to put them in the root.\r\rpom 0]

writing this\r\ronClipEvent (data) {\r&nbsp &nbsp &nbsp &nbsp for (i=301; i<326; i++) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp set (“root.name”+i, “aaa_”+i);\r\rthe result ist that the variables get the value aaa_301, aaa_302, … and not the value that is assigned in the txt-file.\r\rAre the " " on a wrong position?\r\rHartwig

Hi!\r\rmaking the _ infront of root, everything works fine\r\rTHX a lot\r\rHartwig

Just in case (I’m not saying this to you, Hart), it’s usually not a good idea to put an equality as a condition of a for loop (here it’s i=325). i<=325 or i<326.\r\rpom 0]

What did I write ?? Of course there’s a _ in front of root. !!\r\rpom 0]

Yes, you’re right Pom. (i=301; i<326; i++) is better, because = causes the system to get very slow