Need help flushing swfs after the first time they play

:book: Hey…

I need to tweak some code that i have. I have a container file that loads all the swfs, and what’s happening is that as the container loads each file (files load from an xml file) it plays pretty well.

The next time the swfs play, though, i’m seeing a lot of artifacts during transitions. so i need to unload the movieclips rather than letting them load on top of eachother. make sense?

here’s the container file:

// import tweener
import caurina.transitions.Tweener;

// delay between slides
const TIMER_DELAY:int = 8000;
// fade time between slides
const FADE_TIME:int =    1;

// reference to the current slider container
var currentContainer:Sprite;
// index of the current slide
var intCurrentSlide:int = -1;
// total slides
var intSlideCount:int;
// timer for switching slides
var slideTimer:Timer;
// slides holder
var sprContainer1:Sprite;
var sprContainer2:Sprite;
// slides loader
var slideLoader:Loader;
// url to slideshow xml
var strXMLPath:String = "slideshow-data.xml";
// slideshow xml loader
var xmlLoader:URLLoader;
// slideshow xml
var xmlSlideshow:XML;

function init():void {
    // create new urlloader for xml file
    xmlLoader = new URLLoader();
    // add listener for complete event
    xmlLoader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
    // load xml file
    xmlLoader.load(new URLRequest(strXMLPath));
    
    // create new timer with delay from constant
    slideTimer = new Timer(TIMER_DELAY);
    // add event listener for timer event
    slideTimer.addEventListener(TimerEvent.TIMER, switchSlide);
    
    // create 2 container sprite which will hold the slides and
    // add them to the masked movieclip
    sprContainer1 = new Sprite();
    sprContainer2 = new Sprite();
    mcSlideHolder.addChild(sprContainer1);
    mcSlideHolder.addChild(sprContainer2);
    
    // keep a reference of the container which is currently
    // in the front
    currentContainer = sprContainer2;
    
}
    
function onXMLLoadComplete(e:Event):void {
    // create new xml with the received data
    xmlSlideshow = new XML(e.target.data);
    // get total slide count
    intSlideCount = xmlSlideshow..image.length();
    // switch the first slide without a delay
    switchSlide(null);
}
    
function fadeSlideIn(e:Event):void {
    // add loaded slide from slide loader to the
    // current container
    currentContainer.addChild(slideLoader.content);
    // clear preloader text
    // fade the current container in and start the slide timer
    // when the tween is finished
    Tweener.addTween(currentContainer, {alpha:1, time:FADE_TIME, onComplete:function() { slideTimer.start(); }});
}

function switchSlide(e:Event):void {
    // check, if the timer is running (needed for the
    // very first switch of the slide)
    if(slideTimer.running)
        slideTimer.stop();
    
    // check if we have any slides left and increment
    // current slide index
    if(intCurrentSlide + 1 < intSlideCount)
        intCurrentSlide++;
    // if not, start slideshow from beginning
    else
        intCurrentSlide = 0;
    
    // check which container is currently in the front and
    // assign currentContainer to the one that's in the back with
    // the old slide
    if(currentContainer == sprContainer2)
        currentContainer = sprContainer1;
    else
        currentContainer = sprContainer2;
    // hide the old slide
    
    // bring the old slide to the front
    mcSlideHolder.swapChildren(sprContainer2, sprContainer1);
    currentContainer.alpha = 0;
    // create a new loader for the slide
    slideLoader = new Loader();
    // add event listener when slide is loaded
    slideLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeSlideIn);
    // add event listener for the progress
    //slideLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
    // load the next slide
    slideLoader.load(new URLRequest(xmlSlideshow..image[intCurrentSlide].@src));
    
    // show description of the next slide
    // show current slide and total slides
}

// init slideshow
init();

and here’s the code from one of the external swfs (and yes, i know i need to clean up my code and just work with one tween engine. i’ll get there.):


import fl.transitions.Tween;
import fl.transitions.easing.*;
import com.greensock.easing.*;
import com.greensock.TweenMax;

var alphaPeople:Tween = new Tween(people_mc, "alpha", Strong.easeOut, 0, 1, 2, true);
var alphaBottle:Tween = new Tween(bottle_mc, "alpha", Strong.easeOut, 0, 1, 3, true);
TweenMax.from(bottle_mc, 3, {x:1008, y:20, ease:Circ.easeOut});

//var tweenBottle:Tween = new Tween(bottle_mc, "x", Strong.easeOut, 1008, 300, 3, true);

TweenMax.from(head_mc, 3, {x:100, y:37, ease:Circ.easeOut});
//var tweenHead:Tween = new Tween(head_mc, "x", Strong.easeOut, 100, 229, 3, true);
var alphaHead:Tween = new Tween(head_mc, "alpha", Strong.easeOut, 0, 1, 3, true);


var str:String = "text";

var i:uint = 0;

var myDelay:Timer = new Timer(3000);
myDelay.addEventListener(TimerEvent.TIMER, showMessage);
myDelay.start();

function showMessage(event:TimerEvent):void{

var timer:Timer = new Timer (50);

timer.start();

timer.addEventListener(TimerEvent.TIMER,gotime);

function gotime(e:TimerEvent) {
    
    textbox1_txt.appendText(str.charAt(i));
    
    i++;
    
        if (i >= str.length) {
            
            timer.stop();
            
        }
    }
}

any help is appreciated. i haven’t worked with as3 in over a year.
thanks!