# External SWFs with transition

**URL:** <https://forum.kirupa.com/t/external-swfs-with-transition/312521>\
**Category:** flash\
**Created:** [August 5, 2010, 4:14pm UTC](https://forum.kirupa.com/t/external-swfs-with-transition/312521 "2010-08-05T16:14:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lanawylma](https://avatars.discourse-cdn.com/v4/letter/l/58f4c7/32.png) [@lanawylma](https://forum.kirupa.com/u/lanawylma)\
**Post date:** [August 5, 2010, 4:14pm UTC](https://forum.kirupa.com/t/external-swfs-with-transition/312521/1 "2010-08-05T16:14:53Z")

</div>

Hi All… I"m very new to AS in general…

I’m trying to have a simple slideshow with external SWFs that outomatic and onClick…I achieved it except the abrupt white space after the unloaded clip goes away… I have this code and I’m not getting any errors - but I mut not have it connected somehow because the fade out is still not there… Can someone please please help me with this… I really appreciate any help ahead of thime…

//Import classes for easier use  
import fl.transitions.Tween;  
import fl.transitions.TweenEvent;  
import fl.transitions.easing.\*;

//Timer  
var slideDuration:uint = 8000; // or use whatever  
var slideTimer:Timer=new Timer(slideDuration,0);  
slideTimer.addEventListener(TimerEvent.TIMER,autoAdvanceF);  
slideTimer.start();

var btnA:Array = [one\_btn,two\_btn,three\_btn];  
var previousBtn:SimpleButton = one\_btn // use class type of your buttons

function autoAdvanceF(e:TimerEvent):void{  
nextButtonF(previousBtn).dispatchEvent(new MouseEvent(MouseEvent.CLICK));  
}

function nextButtonF(btn:SimpleButton):SimpleButton{ // use class type of your buttons  
for(var i:uint=0;i\<btnA.length;i++){  
if(btnA\*==btn){  
return btnA[(i+1)%btnA.length];  
}  
}  
return null;  
}

//Load external SWF into main  
var Xpos:Number = 0;  
var Ypos:Number = 0;  
var swf:MovieClip;  
var loader:Loader = new Loader();

var defaultSWF:URLRequest = new URLRequest(“swfs/one\_btn.swf”);

var target\_mc:MovieClip = new MovieClip();  
addChild(target\_mc);  
var target\_mc2:MovieClip = new MovieClip();  
addChild(target\_mc2);

//load swf to movieClip

target\_mc.addChild(loader);

//variables that store current content clip and current content indes  
var activeTarget:MovieClip = new MovieClip();

loader.load(defaultSWF);  
loader.x = Xpos;  
loader.y = Ypos;  
addChildAt(loader,0);

//Btns universal function (whenver any button is clicked, the loader will be removed

function btnClick(event:MouseEvent):void {  
if (target\_mc.alpha \> 0) {  
target\_mc.alpha -=10;  
}  
if(target\_mc2.alpha \< 100) {  
target\_mc2.alpha +=10;  
};

slideTimer.reset();

slideTimer.start();

```
previousBtn = SimpleButton(event.currentTarget);
removeChild(loader);

var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
var myTween:Tween = new Tween(loader, "alpha", None.easeIn, 0, 2, 1, true);

loader.load(newSWFRequest);
loader.x = Xpos;
loader.y = Ypos;
addChildAt(loader,0);

```

}

loader.addEventListener(Event.ENTER\_FRAME, onEnter);

// Movie level enterFrame event handler that will fade down object 1 (if it’s alpha ishigher than 0) and fade up object 2 (if its aslpha is less than 100)

function onEnter(event:Event):void {  
if (target\_mc.alpha \> 0) {  
target\_mc.alpha -= 10;  
}  
if (target\_mc2.alpha \< 1 ) {  
target\_mc2.alpha +=10;  
}  
loader.removeEventListener(Event.ENTER\_FRAME, onEnter);  
trace (“the movie clip is faded in”);  
}

/// Button Listerners  
one\_btn.addEventListener(MouseEvent.CLICK,btnClick);  
two\_btn.addEventListener(MouseEvent.CLICK,btnClick);  
three\_btn.addEventListener(MouseEvent.CLICK,btnClick);
