Preplexing prob with Arrays and Functions

Well, Ive been trying to pin down the problem with this code for several hours now, but no luck.

This is what I do:
I convert a string with numbers to an array, and pass that array as a parameter to a function, which is supposed to use it in a switch-case statement. But that wont work.


// Create string with numbers
s_StringToArray = "0, 1, 3, 2";

// Convert String to Array	
arr_myArray = s_StringToArray.split(", ");

// Call function and submit array as parameter
fn_LoadContent(arr_myArray);	


// Function that recieves the array as a parameter, and uses it in a switch-statement
function fn_LoadContent(arr_myArray){
	
	// This debug will output the correct array
	trace ("arr_myArray = " + arr_myArray);
	
	// Select depending on what number is in arr_myArray[1]
	// ! This is where it goes wrong - the switch-case wont use the array submitted array.
	// ! If I on the other hand sends an array which has NOT been converted from a String, it WILL work.
	switch(arr_myArray[1]){
		case 1:	
			// do something
		break;
		case 2:
			// do something else
		break;
	}
}

If I on the other hand use a predefined array (not converted from sting) and send it along with the function, it WILL work.


// Define Array	
arr_myArray = [0, 1, 3, 2];

// Call function and submit array as parameter
fn_LoadContent(arr_myArray);	


// Function that recieves the array as a parameter, and uses it in a switch-statement
function fn_LoadContent(arr_myArray){
	
	// This debug will output the correct array
	trace ("arr_myArray = " + arr_myArray);
	
	// Select depending on what number is in arr_myArray[1]
	// ! This works
	switch(arr_myArray[1]){
		case 1:	
			// do something
		break;
		case 2:
			// do something else
		break;
	}
}

And to add to the confusion, in the first example the debug-code (trace) will output the correct array, meaning it HAS been passed along as a parameter.

This is driving me insane :crazy: