dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Can't get xml images to show up in flash?

  1. #1
    Member
    Join Date
    Jul 2001
    Location
    USA
    Posts
    78

    Can't get xml images to show up in flash?

    I've got a flash movie that is supposed to load xml images from a separate folder. Unfortunately, they aren't showing up?!?! I've checked my path, spelling, file name etc. but can't see it. I think i've been starring at this too long. They are supposed to load into a movieclip with an instance name of picture. Can anyone tell me what i'm doing wrong?

    Actionscript:
    Code:
    //loads xml images with next and previous arrows
    function loadXML(loaded) {
    if (loaded) {
    xmlNode = this.firstChild;
    image = [];
    description = [];
    total = xmlNode.childNodes.length;
    for (i=0; i<total; i++) {
    image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
    }
    firstImage();
    } else {
    content = "file not loaded!";
    }
    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("sanctuary.xml");
    /////////////////////////////////////
    listen = new Object();
    listen.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
    prevImage();
    } else if (Key.getCode() == Key.RIGHT) {
    nextImage();
    }
    };
    Key.addListener(listen);
    previous_btn.onRelease = function() {
    prevImage();
    };
    next_btn.onRelease = function() {
    nextImage();
    };
    /////////////////////////////////////
    p = 0;
    this.onEnterFrame = function() {
    filesize = picture.getBytesTotal();
    loaded = picture.getBytesLoaded();
    preloader._visible = true;
    if (loaded != filesize) {
    preloader.preload_bar._xscale = 100*loaded/filesize;
    } else {
    preloader._visible = false;
    if (picture._alpha<100) {
    picture._alpha += 10;
    }
    }
    };
    function nextImage() {
    if (p<(total-1)) {
    p++;
    if (loaded == filesize) {
    picture._alpha = 0;
    picture.loadMovie(image[p], 1);
    desc_txt.text = description[p];
    picture_num();
    }
    }
    }
    function prevImage() {
    if (p>0) {
    p--;
    picture._alpha = 0;
    picture.loadMovie(image[p], 1);
    desc_txt.text = description[p];
    picture_num();
    }
    }
    function firstImage() {
    if (loaded == filesize) {
    picture._alpha = 0;
    picture.loadMovie(image[0], 1);
    desc_txt.text = description[0];
    picture_num();
    }
    }
    function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
    }
    XML
    Code:
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <viewer>
    
    <images id="0" img="sanctuary/sanctuary1.jpg"/>
    
    <images id="1" img="sanctuary/sanctuary2.jpg"/>
    
    <images id="2" img="sanctuary/sanctuary3.jpg"/>
    
    <images id="3" img="sanctuary/sanctuary4.jpg"/>
    
    <images id="4" img="sanctuary/sanctuary5.jpg"/>
    
    <images id="5" img="sanctuary/sanctuary6.jpg"/>
    
    <images id="6" img="sanctuary/sanctuary7.jpg"/>
    
    <images id="7" img="sanctuary/sanctuary8.jpg"/>
    
    <images id="8" img="sanctuary/sanctuary9.jpg"/>
    
    <images id="9" img="sanctuary/sanctuaryl0.jpg"/>
    
    <images id="10" img="sanctuary/sanctuary11.jpg"/>
    </viewer>
    Thanks!
    Leah5569

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    change these two lines -
    PHP Code:
    image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue
    to -
    PHP Code:
    image[i] = xmlNode.childNodes[i].attributes.img;
    description[i] = xmlNode.childNodes[i].attributes.id
    hth

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