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 7730009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:06:53+00:00 2026-06-01T06:06:53+00:00

I have done a simple code for a slideshow that dynamicly loads images from

  • 0

I have done a simple code for a slideshow that dynamicly loads images from a subfolder, depending on what is listet in a text file.

the code:

import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Loader;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.display.Bitmap;
import flash.display.BitmapData;

public class slideshow extends MovieClip {

    public var listLoader:URLLoader;
    public var newImgList:Array;
    public var imgX:int = 0;
    public var container:MovieClip;

    public function slideshow() {
        container = new MovieClip();
        stage.addChild(container);

        listLoader = new URLLoader(new URLRequest("./slideshow.txt"));
        listLoader.addEventListener(Event.COMPLETE, initImages);
    }

    public function initImages(event:Event):void {
        var imgList:Array = listLoader.data.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/);
        newImgList = new Array();
        for(var line:int = 0; line < imgList.length; line++ ) {
            if(imgList[line].indexOf(".png") != -1 || imgList[line].indexOf(".jpg") != -1) {
                newImgList.push(imgList[line]);
            }
        }
        loadImage();
    }

    public function loadImage():void {
        for(var loaderNum = 0; loaderNum < newImgList.length; loaderNum++) {
            var imgLoader = new Loader();
            imgLoader.load(new URLRequest("./slideshow/" + newImgList[loaderNum]));
            imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgInit);
        }
    }

    public function imgInit(event:Event):void {
        var imgBmp:BitmapData = event.target.content.bitmapData;
        var img:Bitmap = new Bitmap(imgBmp);
        img.height = 150;
        img.scaleX = img.scaleY;
        img.y = 0;
        img.x = imgX;
        imgX = (imgX + img.width + 10);
        container.addChild(img);
    }
}

well actually it works fine for me except for that the images are displayed in a almost random order.

i guess the code is loading some images too slow, so some of them are added to the movieclip although they are loaded after the one that should go next.

so what i mean :

1.png is loaded

1.png is added

2.png is loaded

3.png is loaded

3.png is added

2.png is added

so my question:

is there any other propper/better way to make that slideshow load images from a textfile where just the full names of the images ( that are in a subfolder ) are listet ?

thanks for any suggestions.

g.r.

  • 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-06-01T06:06:55+00:00Added an answer on June 1, 2026 at 6:06 am

    Queue your image loading to have them ordered.

    Rough example:

    var queue:Array = []; // Populated from your text/whatever file.
    // If you want the images to load from first to last you will need
    // to use queue.reverse() once you get the filenames.
    
    /**
     * Beings loading the next image in queue.
     * Ignored if the queue has no remaining items.
     */
    function loadNext():void
    {
        if(queue.length > 0)
        {
            var imgSrc:String = queue.pop();
    
            var ldr:Loader = new Loader();
            ldr.load(new URLRequest(imgSrc));
    
            ldr.addEventListener(Event.COMPLETE, _done);
        }
    }
    
    
    /**
     * Called once a Loader instance has finished loading a resource.
     * @param e Event.COMPLETE.
     */
    function _done(e:Event):void
    {
        e.target.removeEventListener(Event.COMPLETE, _done);
        container.addChild(e.target as DisplayObject);
    
        // Begin loading the next image in queue.
        loadNext();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple code that looks up a text file, reads the line
I am trying to perform a simple operation that i have done alot in
In my project, user will upload videos. So i have done simple code to
I have done simple java app for blackberry, while building am getting following error.
I have recently done a very simple highlighting with jQuery and a highlight plugin.
I hope I am not missing something very simple here. I have done a
I've done some simple string -> DateTime conversions before using DateTime.ParseExact(), but I have
I'm looking for a simple way to have this done. I would to have
I want to do a simple drag-drop using jQuery. I have not done anything
I have done a bit of research into this and it seems that the

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.