...

View Full Version : Resolved Child doesn't unload in xml slideshow



marilynn.fowler
07-30-2009, 04:09 AM
This is supposed to be a continuous XML slideshow; once the new image completely fades in, the previous image should be removed from the stage. The previous image is not being removed

How do I fix this problem? Here's my code:

import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;

var miniFade:Tween;

var firstTime:Boolean = true;

var miniTimer:Timer = new Timer(5000); //runs every 5 seconds
miniTimer.addEventListener(TimerEvent.TIMER, evalSlideNo);

var miniFile:XML;

var miniLoader:Loader;
var whichMini:String; //keeps track of the image URL
var miniNum:Number = 0; //keeps track of which image you're on
var totalMini:Number;

var miniXMLLoader:URLLoader = new URLLoader();
miniXMLLoader.load(new URLRequest("photos.xml"));
miniXMLLoader.addEventListener(Event.COMPLETE, miniXMLLoaded);

function miniXMLLoaded(event:Event):void {
miniFile = XML(event.target.data);
whichMini = miniFile.about.image[miniNum].imgURL;
totalMini = miniFile.about.*.length();

miniLoader = new Loader();
miniLoader.load(new URLRequest(whichMini));
miniLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeMini);
}

function fadeMini(event:Event):void {
addChild(miniLoader);
miniLoader.width = 384;
miniLoader.height = 308;
miniFade = new Tween(miniLoader, "alpha", None.easeNone, 0, .4, 1, true);
miniTimer.start();

if (firstTime = false) {
miniFade.addEventListener(TweenEvent.MOTION_FINISH, removeOld);
}
else (firstTime = false);
}

function removeOld(event:TweenEvent):void {
removeChildAt(0);
}

function evalSlideNo(event:TimerEvent):void {
miniNum++;
if (miniNum == miniFile.about.*.length()) {
miniNum = 0;
}
changeMini(miniNum);
trace(miniNum);
}

function changeMini(miniNum:Number):void {
miniTimer.stop();
miniLoader = new Loader();
miniLoader.load(new URLRequest(miniFile.about.image[miniNum].imgURL));
miniLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeMini);
}

marilynn.fowler
07-30-2009, 07:29 AM
Never mind. Syntax and location errors.
1. firstTime ==
2. removeChildAt(1)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum