I loaded Image with ImageLoader like below code where resourceInfoObj is custom class holding position and size information related to image.
private var imageLoader:ImageLoader;
private var imageContainer:ContentDisplay;
resourceInfoObj = resourceListObj.getResourceInfoById(ResourceList.SELECTED_ITEM_IMAGE);
imageLoader = new ImageLoader(_itemPhotoUrl, new ImageLoaderVars()
.name("itemImage")
.bgColor(0xFF0000)
.centerRegistration(true)
.scaleMode("proportionalInside")
.onComplete(itemPhotoLoadComplete)
.x(resourceInfoObj.x)
.y(resourceInfoObj.y)
.width(resourceInfoObj.width)
.height(resourceInfoObj.height));
imageLoader.load();
and Later When Complete Event if Fired I Added Content to Stage Like below.
private function itemPhotoLoadComplete(e:LoaderEvent):void
{
imageContainer = e.target.content;
this.addChild(imageContainer);
}
now after loading that photo i when use click Next/Some Button on the stage i want to remove that loaded image/imageContainer from stage and replace it with updated new url image. but when I try to remove image Loader Remains on stage.
to add New Updated Image i use code like below
public function removePreviousImage():void
{
if (imageContainer != null)
{
removeChild(imageContainer);
}
}
public function UpdateContent(Newurl:String):void
{
removePreviousImage();
resourceInfoObj = resourceListObj.getResourceInfoById(ResourceList.SELECTED_ITEM_IMAGE);
imageLoader.url = Newurl;
imageLoader.vars =new ImageLoaderVars()
.name("itemImage")
.bgColor(0xFF0000)
.centerRegistration(true)
.scaleMode("proportionalInside")
.onComplete(itemPhotoLoadComplete)
.x(resourceInfoObj.x)
.y(resourceInfoObj.y)
.width(resourceInfoObj.width)
.height(resourceInfoObj.height);
imageLoader.load();
}