dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Loading one XML doc at a time

  1. #1
    Senior Member
    Join Date
    Oct 2000
    Location
    Hannover, Germany
    Posts
    164

    Loading one XML doc at a time

    Hi, I'm working on aproject where I want to load specific lists of product broschures into a ListBox component when the user clicks on a button. When the user clicks on another button, the list box should clear itself and load the new list. How do I go about loading the several xml files and "holding" them until they're needed? I have so much scripting on my buttons, i know there must be an easier way of going about this. here's a sample of my button script (Flash MX 2004):

    on Button:

    ordnerMC_06.pfeil06_btn.onRelease=function(){
    //check variable-it "jumps out"
    if(out){
    out=false;
    _parent.broschure_01.titel="News";
    _parent.broschure_01.pdf_list.removeAll();


    }else{
    //set var
    out=true;
    _root.cardnumber=6;
    }
    };

    on another actions layer to load the xml:

    //News
    XML.prototype.ignoreWhite = true;
    news_xml = new XML();
    news_xml.load("list_06.xml");
    trace("news is loaded");
    news_xml.onLoad = function() {
    var listItem = this.firstChild;

    for (var i = 0; i<listItem.childNodes.length; i++) {
    ThisNode = listItem.childNodes[i].attributes;
    _parent.broschure_01.pdf_list.addItem(ThisNode.pdf NAME, ThisNode.pdfURL);
    }
    _parent.broschure_01.pdf_list.setChangeHandler("la unchPDF");
    };



    stop();

    --I wish I ould put a load function on the release handler of my button, but how do I go about calling the function and where do I write the function? I need this function six times with six different xml documents, so could I theoretically write a global function on the root and just call it, specifying the xml name each time when the user clicks on a button?

    Any help is much appreciated- tanks in advance!
    miakazi

  2. #2
    Senior Member
    Join Date
    Oct 2000
    Location
    Hannover, Germany
    Posts
    164
    ok, I've tried to take another approach...I have defined the load_XML and XML_Name functions in the first frame, then on the buttons, call the functions and pass the variables needed to load the rigth xml docs, but I'm still not loading anything into the listbox...

    //first frame:

    var cardnumber:Number;
    //function for pdfs
    function xml_name(){
    var xmlName:String;
    var xmlStuck:String;
    var i:Number;
    i=cardnumber;
    xmlName=this["papers_0"+i+".xml"];
    xmlStuck=this["stuck"+i+"_xml"];
    trace(i);
    }
    function loadXML(){
    XML.prototype.ignoreWhite = true;
    xmlStuck = new XML();
    xmlStuck.load(xmlName);
    var listItem = this.firstChild;
    for (var i = 0; i<listItem.childNodes.length; i++) {
    ThisNode = listItem.childNodes[i].attributes;
    _parent.broschure_01.pdf_list.addItem(ThisNode.pdf NAME, ThisNode.pdfURL);
    }
    _parent.broschure_01.pdf_list.setChangeHandler("la unchPDF");
    };
    //launch pdf
    function launchPDF(ThisNode) {
    var url = ThisNode.getSelectedItem().data;
    fscommand("exec", url+".exe");
    }

    //button onRelease() action:
    ordnerMC_01.pfeil01_btn.onRelease=function(){
    //check variable
    if(out){
    out=false;
    _parent.broschure_01.titel="Technical Broschures";
    //broschure_01.pdf_list.removeAll();
    _root.xml_name();
    trace(_root.xmlName);
    _root.loadXML();
    trace("Technical Broschures is loaded");
    }else{
    //set var
    out=true;
    _root.cardnumber=1;
    }
    };

    please take a lokk if you have time, I would really appreciate it!
    thanks, miakazi

  3. #3
    Senior Member
    Join Date
    Oct 2000
    Location
    Hannover, Germany
    Posts
    164
    ok, I'm still not getting any response. I'm trying to trace the xmlName variablr, but am only getting "error opening url" and then the path to the xml doc. Does anyone have an idea how to do this or what I'm doing wrong????
    miakazi

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