# Problem loading swf

**URL:** <https://forum.kirupa.com/t/problem-loading-swf/277838>\
**Category:** flash\
**Created:** [December 17, 2008, 10:00pm UTC](https://forum.kirupa.com/t/problem-loading-swf/277838 "2008-12-17T22:00:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ParanoidAndroid](https://avatars.discourse-cdn.com/v4/letter/p/b19c9b/32.png) [@ParanoidAndroid](https://forum.kirupa.com/u/ParanoidAndroid)\
**Post date:** [December 17, 2008, 10:00pm UTC](https://forum.kirupa.com/t/problem-loading-swf/277838/1 "2008-12-17T22:00:19Z")

</div>

hi  
i have several buttons in a menu with instance names. i added listeners to every one of them to load an external swf file when clicked. when the loading is completed, i call a function to place this swf into a movieClip. the code would be something like this:

mainLoader:Loader=new Loader();  
mainLoader.contentLoaderInfo.addEventListener(Even t.COMPLETE,placeMain);

mainContainer:MovieClip=new MovieClip();  
addChild(mainContainer);

scene1.addEventListener(MouseEvent.CLICK,loadswf);

function loadswf(evt:MouseEvent):void  
{   
mainLoader.load(new URLRequest(“Files/”+evt.target.name+".swf"));  
}

function placeMain(evt:Event):void  
{  
if(mainContainer.numChildren!=0)  
{  
mainContainer.removeChildAt(0);  
}  
mainContainer.addChild(evt.target.content);  
mainLoader.unload();  
}

well the problem is that i get an error that says “The supplied DisplayObject must be a child of the caller.”, “Loader/unload”. or something like that.  
why is this? what’s wrong? any idea?  
i would appreciate any help, thanks.
