Setting array values to variables in another array

I have some variables created on the main timeline and a mc called options which will be where those variables can be manipulated.

A way I’ve tried to this is by creating a first array(array1) and populating it will all the variable names found on the main timeline, and another array(array2) containing the values of the variables the user has changed(which are displayed on some dynamic text fields). To make these changes, an “apply” button is pressed which will set the values found in array2 to the variables in array1.

So…

Code:


//variables on the main or root timeline
var1 = 1; 
var2 = 2; 

//... 
//within options mc timeline
array1 = [var1, var2]; 
array2 = [var1Display, var2Display]; 

apply.onRelease = function() { 
//set values in array2 to variables in array1 and update the main timeline's variables
//... 
}  

How would you do this so that var1, var2… are updated properly according to the values found in array2?

And because array2 contains strings(read from dynamic textfields), how do you deal with that since var1 and var2 are numbers?

hope this all makes sense to everyone :ko: