# Load/unload external swf with fadein / fadeout

**URL:** <https://forum.kirupa.com/t/load-unload-external-swf-with-fadein-fadeout/315723>\
**Category:** flash\
**Created:** [November 2, 2010, 9:50pm UTC](https://forum.kirupa.com/t/load-unload-external-swf-with-fadein-fadeout/315723 "2010-11-02T21:50:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsunami5150](https://avatars.discourse-cdn.com/v4/letter/t/8797f3/32.png) [@tsunami5150](https://forum.kirupa.com/u/tsunami5150)\
**Post date:** [November 2, 2010, 9:50pm UTC](https://forum.kirupa.com/t/load-unload-external-swf-with-fadein-fadeout/315723/1 "2010-11-02T21:50:38Z")

</div>

Hello everyone,

I have a very simple main.swf with buttons in a mc. once a button is clicked it loads and external swf file into x y pos.

How can I set it up so when the external swf loads with a fade in and the other one fades out? Can anyone help?

This is my existing code now!

* * *

var Xpos:Number = 0;  
var Ypos:Number = 75;  
var swf:MovieClip;  
var loader:Loader = new Loader();

var defaultSWF:URLRequest = new URLRequest(“swfs/home.swf”);

loader.load(defaultSWF);  
loader.x = Xpos;  
loader.y = Ypos;  
addChild(loader);  
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Btns Universal function  
function btnClick(event:MouseEvent):void {

```
removeChild(loader);
var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
loader.load(newSWFRequest);
loader.x = Xpos;
loader.y = Ypos;
addChild(loader);

```

}

// Btn listeners  
menu\_mc.home.addEventListener(MouseEvent.CLICK, btnClick);  
menu\_mc.aboutus.addEventListener(MouseEvent.CLICK, btnClick);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

If anyone could shed some light on how I might be able to accomplish this with this code. This code is from [adamkhoury.com](http://adamkhoury.com) it works great but just need it to fade in and out the swf files.

peace
