Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    San Francisco
    Posts
    455
    Thanks
    19
    Thanked 15 Times in 15 Posts

    Child doesn't unload in xml slideshow

    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:
    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);
    }
    Last edited by marilynn.fowler; 07-30-2009 at 07:58 AM.
    Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read. Groucho Marx

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    San Francisco
    Posts
    455
    Thanks
    19
    Thanked 15 Times in 15 Posts
    Never mind. Syntax and location errors.
    1. firstTime ==
    2. removeChildAt(1)
    Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read. Groucho Marx


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •