I wonder if someone can help me with removeChild
i made a class preloadContent, it preloads content
but when i want to load the next external image or swf he doesn’t remove the old content, can someone help me with that, its a reocuring problem for me i dont understand the removechild stuff.
this is my class:
package
{
import gs.*;
import gs.easing.*;
import flash.display.*;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.*;
import flash.net.*;
public class PreloadContent extends MovieClip
{
public var main;
public var xmlmenu;
public var imageLoader:Loader;
public var container;
public var placeholder;
public var changeSize;
public var url;
public var firstTime:Boolean = true;
public var hoog;
public var breed;
public function PreloadContent(mainClass, container, placeholder, changeSize):void
{
this.main = mainClass;
this.container = container;
this.placeholder = placeholder;
this.changeSize = changeSize;
}
public function preloadContent(contentUrl, hoog, breed):void
{
this.url = contentUrl;
// Show Preloader
this.placeholder.preloader.visible = true;
this.hoog = hoog;
this.breed = breed;
// Set properties on my Loader object
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
public function imageLoaded(e:Event):void {
// Hide Preloader
this.placeholder.preloader.visible = false;
this.changeSize.changeSize(this.hoog, this.breed);
// The container animation takes 1 seconde so wait until the animation is done and then load the image
TweenLite.to(this.container, 1, {onComplete:placeContent});
}
public function placeContent():void
{
// remove content
if (firstTime == false)
{
this.placeholder.imageLoadArea.removeChild(imageLoader);
}
// Load Content
this.placeholder.imageLoadArea.addChild(imageLoader);
trace(image);
firstTime = false;
}
public function imageLoading(e:ProgressEvent):void {
// Get current download progress
var loaded:Number = e.bytesLoaded / e.bytesTotal;
// Send progress info to "preloader" movie clip
this.placeholder.preloader.SetProgress(loaded);
}
}
}