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

  • Home
  • SEARCH
  • 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 735195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:27:39+00:00 2026-05-14T07:27:39+00:00

I’m having some problems figuring out how to organise data pulled off XML in

  • 0

I’m having some problems figuring out how to organise data pulled off XML in cells within a container. I’m sure this should be a basic thing in AS3, but my head’s fried.. can anyone help?

Basically an array if fed to callThumbs() which iterates through it and compares the entries with preloaded XML _my_images. If match is found, it’s sent to processXML which loads all relevant info and loads a .jpg thumbnail. All this is then fed to createCell which creates a specific cell with position values depending on x_counter and y_counter values (4 cells in a row) and adds the cell into a container _container_mc.

The Problem: This all works fine and looks fine, the problem is that the cells within the container do not display in descending order. They are in random order, probably because some of the .jpg’s takes longer to load etc. How do I easily organise the cells within the container in descending order by the XML .id value? Or how do I tell Flash to wait till the thumbnail and data is loaded and the cell created and added?

Thanks guys, would really appreciate all the help!

PJ

//Flash (AS3)       

       function callThumbs(_my_results:Array):void {   // selector = 1 for specific items, 2 for search items

            var _thumb_url:XML;

            for (var r:Number=0; r < _my_results.length; r++) { // iterate through results vector, compare with _my_images XML .id

                for (var i:Number=0; i < _my_images.length(); i++) {

                    if (_my_images[i].@id.toXMLString() == _my_results[r]) {

                        _thumb_url=_my_images[i];

                        processXML(_thumb_url, i);

                    }

                }
            }

        } // End callThumbs


        function processXML(imageXML:XML, num:Number) { // Processes XML data and loads .jpg thumbnail

            var _thumb_loader=new Loader();

            _thumb_loader.load(new URLRequest("thumbs/thumb_sm/" + imageXML.@id + "_st.jpg"));
            _thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,thumbLoaded);
            _thumb_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, urlNotFound);

            var id:XMLList = new XMLList;
            id = imageXML.@id;
            var description:XMLList = new XMLList;
            description = imageXML.@description;

            function urlNotFound(event:IOErrorEvent):void {
                trace("The image URL '" + String(imageXML.@id) + "' was not found.");
            }

            function thumbLoaded(e:Event):void {
                    var imageLoader:Loader = Loader(e.target.loader);
                    var bm:Bitmap = Bitmap(imageLoader.content);

                    createCell(bm, id, description, num);
                    adjustFooterBar(); // Adjust bottom footer
            }


        } // End processXML



        private function createCell(_image:Bitmap, _id, _description:String, _position):void { // Creates a cell with data, add to container

            var _cell_mc = new CellTitle();         

            _cell_mc.initCell(_image, _id, _description, _position, x_counter, y_counter);

            if (x_counter+1 < 4) {
                x_counter++;
            } else {
                x_counter = 0;
                y_counter++;
            }

            _container_mc.addChild(_cell_mc); // movieclip container

        } // End createCell
  • 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-14T07:27:39+00:00Added an answer on May 14, 2026 at 7:27 am

    In order to tell flash to wait for each thumbnail, you will have to wait for each one to load before loading the next. You should be able to easily modify your code to handle this. The code below may need some changes, I am more just trying to illustrate my point.

    (AS3)
       // create these outside of the functions so they can be updated/used by both
       var i:Number = 0;
       var totalResults:Number = _my_results.length;
    
       // start loading the first thumbnail
       callThumbs(0);
    
       function callThumbs(resIndex:Number):void { 
    
            var _thumb_url:XML;
            var result = _my_results[resIndex];
    
            for (var n:Number = 0; n < _my_images.length(); i++) {
    
                if (_my_images[n].@id.toXMLString() == result) {
    
                    _thumb_url = _my_images[n];
    
                    processXML(_thumb_url, n);
    
                    /**
                     * break here because we don't want to do another iteration
                     * the complete handler for the thumbnail loader will determine if this function
                     * is to be called again.
                     */
                    break;
                }
    
            }
    
        } // End callThumbs
    
    
        function processXML(imageXML:XML, num:Number) {
    
            var _thumb_loader = new Loader();
    
            _thumb_loader.load(new URLRequest("thumbs/thumb_sm/" + imageXML.@id + "_st.jpg"));
            _thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,thumbLoaded);
            _thumb_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, urlNotFound);
    
            var id:XMLList = new XMLList;
            id = imageXML.@id;
            var description:XMLList = new XMLList;
            description = imageXML.@description;
    
            function urlNotFound(event:IOErrorEvent):void {
                trace("The image URL '" + String(imageXML.@id) + "' was not found.");
            }
    
            function thumbLoaded(e:Event):void {
                    var imageLoader:Loader = Loader(e.target.loader);
                    var bm:Bitmap = Bitmap(imageLoader.content);
    
                    createCell(bm, id, description, num);
                    adjustFooterBar(); // Adjust bottom footer
    
                // determine if there is another thumbnail to be loaded
                if (i < totalResults) {
                    i++;
                    callThumbs(i);
                }
    
            }
    
    
        } // End processXML
    
    
    
        private function createCell(_image:Bitmap, _id, _description:String, _position):void { // Creates a cell with data, add to container
    
            var _cell_mc = new CellTitle();         
    
            _cell_mc.initCell(_image, _id, _description, _position, x_counter, y_counter);
    
            if (x_counter+1 < 4) {
                x_counter++;
            } else {
                x_counter = 0;
                y_counter++;
            }
    
            _container_mc.addChild(_cell_mc); // movieclip container
    
        } // End createCell
    

    Also, just out of curiosity, is this being done on the timeline?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 383k
  • Answers 383k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer According to the built-in internal class PageThemeBuildProvider, asp.net create relative… May 14, 2026 at 10:55 pm
  • Editorial Team
    Editorial Team added an answer Bjarne Stroustrup mentions in his C++0x FAQ about auto: "The… May 14, 2026 at 10:55 pm
  • Editorial Team
    Editorial Team added an answer I used ADAM then LDS for a pretty large scale… May 14, 2026 at 10:55 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.