Calling a function with an array variable as arguments is resetting array?

I’m going to post the full code of the two functions, disregard the “fluff” unrelated to the two functions as it is all working flawless, I’ve tested this HEAVILY and cannot understand why it keeps setting the entire array to undefined!

Any help would be grateful.


// processReplace Function
    function processReplace(transferFiles) {
        var processArray:Array = transferFiles.slice();
        var fileName:String = new String();
        var filesArray:Array = new Array();
        var replaceArray:Array = new Array();
        var exists:String = new String();
        var error:String = new String();
        var promptResult:String = new String();
        // Check
        for (i=0; i<processArray.length; i++) {
            // This is where it bugs up
            **exists = processSearch(transferFiles*[1]);** 
            if (exists == "replace") {
                replaceArray.push(processArray*);
            } else {
                filesArray.push(processArray*);
            }
        }
        // Prompt
        if (replaceArray.length>0) {
            error = "Replace "+replaceArray.length+" item(s):

";
            for (i=0; i<replaceArray.length; i++) {
                error += " - "+replaceArray*[1]+"
";
            }
            promptResult = mSystem.messageBox(error, "Replace Existing Files?", 4);
        }
        // Action          
        if (promptResult == "NO") {
            transferFiles = filesArray;
        } else if (promptResult == "YES") {
            transferFiles = filesArray.concat(replaceArray);
        }
        processTransfer(transferFiles);
    }

The processSearch



    // == processSearch Function
    function processSearch(sentInfo) {
        for (i=0; i<_global.boxFiles.length; i++) {
            if (_global.boxFiles* == sentInfo[1]) {
                return "replace";
                break;
            }
        }
    }

Basically it’s supposed to check to see if the file exists and return as true if it does and add it to a replace array, then the replace array is processed into a single string and put into a dialog box through the flash wrapper prompting them to “replace the files or not”.

It makes the replace array just fine, it actually even has the right “count” in it but it’s setting all the “filenames” to undefined because of the exists = processSearch function.

I even tried to make a new array and run the search just from that one and set the values from the old one and it’s still failing.

Is it because of the “break” or can anyone figure it out? Iknow it’s hard because you can’t use the code :frowning:

** ANY Solution ideas are welcome, even if you think it’s dumb **

Thanks!