Passing a MovieClip reference to a function in an external class

Howdy, folks!

My situation is seemingly simple: I want to create a MovieClip, pass this MovieClip to a function in another class where it will be modified.

The problem is, when I pass the MovieClip as a parameter to a function and start making changes, the changes are only made locally. The “copy” of the MovieClip inside the function gets changed, but the “real” MovieClip back in my main game class remains unchanged.

Here’s the code from my Main class:

var resourceLoader:ExternalResourceLoader = new ExternalResourceLoader();    
var myMovieClip:MovieClip;

function Main() {
   resourceLoader.loadSWFIntoMC("awesomeAnimation.swf",myMovieClip,stage,testCallback);
}

function testCallback() {
   trace(myMovieClip);
   // Returns null. This MovieClip is never created - only the local copy inside the "loadSWFIntoMC" function.
}

And here’s the function being called (from an external .AS class file):


public function loadSWFIntoMC(filename:String, targetMC:MovieClip, parentWindow:Stage, callbackFunction:Function=null) {
            targetMC=new MovieClip();
            targetMC.fullyLoaded=false;
            var loader = new Loader();
            var loadRequest:URLRequest=new URLRequest(filename);
            loader.load(loadRequest);
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE,function(e:Event) {
                targetMC=loader.content;
                parentWindow.addChild(targetMC);
                targetMC.fullyLoaded=true;
                if (callbackFunction!==null) {
                    callbackFunction.call();
                }
            });
        }

Thanks in advance for the help!