Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3951966
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:47:38+00:00 2026-05-20T01:47:38+00:00

i recently started to learn AS3 and i decided to make a portfolio website

  • 0

i recently started to learn AS3 and i decided to make a portfolio website with it. I am loading the information about the websites i created from an external XML file.

Everything its working well but when i load a new picture to the stage the previous picture remains there which in my understanding it shouldn’t happen. As i understood from Adobe’s AS3 Guide once you create a new instance of a loader, the previous one should be erased.

I’ve been looking all over the place for a solution but i can’t find one that will work. I tried using the .unload class and i tried removeChild as well but it keeps giving me errors.

Here is the code i’ve been using:

import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.filters.*;
import flash.display.MovieClip;
import flash.events.MouseEvent; 

var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

xmlLoader.load(new URLRequest("portfolio.xml"));

function LoadXML(e:Event):void {
    xmlData = new XML(e.target.data);
    ParsePortfolio(xmlData);
}

function ParsePortfolio(siteInput:XML):void {

    var titleList:XMLList = siteInput.Site.title;
    var servicesList:XMLList = siteInput.Site.services;
    var urlList:XMLList = siteInput.Site.url;
    var picList:XMLList = siteInput.Site.picture;

    var XX:Number = 0;

    var titleElement:XML = titleList[XX];
    var servicesElement:XML = servicesList[XX];
    var urlElement:XML = urlList[XX];   
    var picElement:XML = picList[XX];

    container_mc.title_txt.text = (titleElement);
    container_mc.services_txt.text = (servicesElement);

    var pictureNumber:String = picElement;
    var my_loader:Loader = new Loader();
    my_loader.load(new URLRequest(pictureNumber));
    container_mc.pictureFrame.addChild(my_loader);  

    next.addEventListener (MouseEvent.CLICK, NbuttonClicked);
    prev.addEventListener (MouseEvent.CLICK, PbuttonClicked);

    function NbuttonClicked(e:Event):void  {

        var t1:Tween = new Tween (container_mc, "alpha", Strong.easeOut, 1, 0, .2, true);

        t1.addEventListener(TweenEvent.MOTION_FINISH, dropbomb);        

        function dropbomb() {       

            XX++;

            if (XX == titleList.length()) {
            XX = 0;
            }

            var titleElement:XML = titleList[XX];
            var servicesElement:XML = servicesList[XX];
            var urlElement:XML = urlList[XX];
            var picElement:XML = picList[XX];

            container_mc.title_txt.text = titleElement;
            container_mc.services_txt.text = servicesElement;
            var pictureNumber:String = picElement;

            trace(pictureNumber);

            var my_loader:Loader = new Loader();
            my_loader.load(new URLRequest(pictureNumber));
            container_mc.pictureFrame.addChild(my_loader);              

            visit.addEventListener (MouseEvent.CLICK, VbuttonClicked);

            function VbuttonClicked(e:Event):void  {

            navigateToURL(new URLRequest(urlElement), "_blank");

            }

            var t2:Tween = new Tween (container_mc, "alpha", Strong.easeOut, 0, 1, .2, true);
        }
    }

    function PbuttonClicked(e:Event):void  {

        var t3:Tween = new Tween (container_mc, "alpha", Strong.easeOut, 1, 0, .2, true);

        t3.addEventListener(TweenEvent.MOTION_FINISH, dropbomb);

        function dropbomb() {

            if ( XX == 0 )
            {
            XX = (titleList.length()) - 1;
            }

            else {XX--;}

            var titleElement:XML = titleList[XX];
            var servicesElement:XML = servicesList[XX];
            var urlElement:XML = urlList[XX];
            var picElement:XML = picList[XX];           

            container_mc.title_txt.text = titleElement;
            container_mc.services_txt.text = servicesElement;
            var pictureNumber:String = picElement;

            var my_loader:Loader = new Loader();
            my_loader.load(new URLRequest(pictureNumber));

            visit.addEventListener (MouseEvent.CLICK, VbuttonClicked);

            function VbuttonClicked(e:Event):void  {

            navigateToURL(new URLRequest(urlElement), "_blank");

            }           

            var t4:Tween = new Tween (container_mc, "alpha", Strong.easeOut, 0, 1, .2, true);

        }   
    }
}

The movie clips are being added to the stage manually. I don’t know if this is causing the problem or if it’s completely unrelated.

To be more specific while the container_mc is fading out, you can see the previous picture which shows that they are stacking rather then being replaced.

I would really appreciate some help, at least i’d like to know what i am doing wrong and to be pointed to the right direction.

I am sorry for the noobish code and for the stupid question, but i’ve really looked all over for the answer, i’ve looked for tutorials on creating XML slideshows and so far nothing helped me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:47:38+00:00Added an answer on May 20, 2026 at 1:47 am

    When you instantiate (and call addChild on it) a loader, it’s added to the display list. It then has to be removed to cease to be in the display list. Instead of instantiating a loader over and over, you can just call Loader.load() on it with a dynamic URLRequest. That way, you’re just sticking with one loader that changes every time you call it.

    For example:

    import flash.events.Event;
    import flash.display.Loader;
    import flash.net.URLRequest;
    
    var _loader:Loader = new Loader();
    var _toLoad:URLRequest = new URLRequest("path.jpg");
    _loader.load(_toLoad);
    addChild(_loader);
    
    loadImage("1.jpg");
    
    function loadImage(path:String):void
    {
        _toLoad = new URLRequest(path);
        _loader.load(_toLoad);
        _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleted, false, 0, true);
    }
    
    function loadCompleted(evt:Event):void
    {
        trace("load completed");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently started to learn about LINQ and came across the OrderBy extension method.
When I started to learn about WPF and MVVM recently, I came across some
I've recently (4 days) started to learn C++ coming from C / Java background.
I've started to learn Ruby recently, and was wondering about which version to learn.
I have recently started to learn about programming for the iPhone and after going
I recently decided to learn and make small 2D game using XNA framework. So
I've recently started to learn about Oracle WebCenter. I'm running Oracle UCM on VBox(downloaded
I recently started learning objective-C and cocoa. I'm slowly starting to learn about memory
I recently started to learn how to use openCL to speed up some part
I've recently started to learn python , and I reached the with statement .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.