A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: XML image array

  1. #1
    Say Hello to my little friend. pimpjacksmack's Avatar
    Join Date
    Apr 2002
    Posts
    95

    XML image array

    I have 8 image boxes that I'm looking to load different images into. I'm using XML to load the images in, as well as description info (i.e. image0 from the XML file loads into "mask0", and so forth). I can get the 1st image to load, but the subsequent images aren't loading. What am I doing wrong?



    Code:
    var loadMovieClip:MovieClipLoader = new MovieClipLoader;
    var loaderObject:Object = new Object;
    function loadXML(loaded) {
        if (loaded) {
            xmlNode = this.firstChild;
            image = [];
            title = [];
            desc = [];
            price = [];
            total = xmlNode.childNodes.length;
            for (i=0; i<total; i++) {
                image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
                title[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
                desc[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
                price[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
            }
            firstImage();
        } else {
            content = "file not loaded!";
        }
    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("images.xml");
    
    
    this.onEnterFrame = function() {
        filesize = this["mask_"+p++].loader.getBytesTotal();
        loaded = this["mask_"+p++].loader.getBytesLoaded();
        preloader._visible = true;
        if (loaded != filesize) {
            preloader.preload_bar._xscale = 100*loaded/filesize;
        } else {
            preloader._visible = false;
            if (this["mask_"+p++].loader._alpha<100) {
                this["mask_"+p++].loader._alpha += 10;
            }
        }
    };
    
    
    function loadPreview(img:String):Void {
    	allLoaders = this["mask_"+p++].loader;
        loadMovieClip.loadClip(img, allLoaders);
        loadMovieClip.addListener(loaderObject);
    }
    
    function firstImage() {
        if (loaded == filesize) {
            this["mask_"+p++].loader._alpha = 0;
            loadPreview(image[0]);
            title.text = title[0];
        }
    }
    I know this may seem a bit convoluted as I understand exactly what I want to happen, but I seem to piece together code from different places to get it to happen.

  2. #2
    Say Hello to my little friend. pimpjacksmack's Avatar
    Join Date
    Apr 2002
    Posts
    95
    All I need is a way to get them to load image x into container x, image y into container y, and so forth...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center