A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: simple as and xml question

  1. #1
    Member
    Join Date
    Jan 2004
    Posts
    87

    simple as and xml question

    Hi there
    I have made an xml preloader for my xml file.
    This script is in frame2 after my stage preloader.
    code:

    stop();
    xmlObject = new Xml();
    xmlObject.load("dbase.xml");
    myInterval = setInterval(loadingXml, 10);
    function loadingXml() {
    if (xmlObject.getBytesLoaded()>=xmlObject.getBytesTot al()) {
    play();
    trace(xmlObject);
    clearInterval(myInterval);
    }
    }


    the xml is preloaded right
    Later in scene i have this script(is not made by me)for an xml menu
    code:

    var array = new Array ();
    var xml = new XML ();
    xml.onLoad = function ()
    {
    var header, link;
    for (var i = 0; i < this.firstChild.childNodes.length; i++)
    {

    if (this.firstChild.childNodes[i].nodeName != null)
    {
    header = this.firstChild.childNodes[i].attributes.header;
    }
    for (var j = 0; j < this.firstChild.childNodes[i].childNodes.length; j++)
    {
    if (this.firstChild.childNodes[i].childNodes[j].nodeName == "link")
    {

    link = this.firstChild.childNodes[i].childNodes[j].firstChild.nodeValue;
    }
    }
    array.push (new struct (header, link));
    }

    printer ();
    };
    //xml.load ("dbase.xml");


    Now i dont what this xml to load now becouse the animation gets freezes for a sec and i want to use the first xmlObject that i had preloaded.

    I have tryed many noobs things like making the _global.xmlOmject
    and than xml = _global.xmlObject; but nothing worked.
    Can u please tell me how to make this work?

    Thank you very much and please excuse me english.

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    You don't need to preload the XML like you're doing.
    That's what the onLoad() does: it's triggered when the XML finishes loading.
    code:

    stop();
    xmlObject = new XML();
    myInterval = setInterval(loadingXml, 10);
    xml.onLoad = function()
    {
    play();
    trace(xmlObject);
    };
    xmlObject.load("dbase.xml");


    And you're right, you don't need to load the xml again.
    Just use the one you've loaded already.
    Replace this with xmlObject (or the correct target path to it).
    code:

    for (var i = 0; i < xmlObject .firstChild.childNodes.length; i++) {
    if (xmlObject .firstChild.childNodes[i].nodeName != null) {
    header = xmlObject .firstChild.childNodes[i].attributes.header;
    }
    for (var j = 0; j < xmlObject .firstChild.childNodes[i].childNodes.length; j++) {
    if (xmlObject .firstChild.childNodes[i].childNodes[j].nodeName == "link") {
    link = this.firstChild.childNodes[i].childNodes[j].firstChild.nodeValue;
    }
    }
    array.push(new struct(header, link));
    }
    printer();


  3. #3
    Member
    Join Date
    Jan 2004
    Posts
    87
    Hi
    thanks for the replay...
    i have made the changes it works but i still got that small freezes in my animation, so even if i preload the xml first flash stil freez when puting xml on stage.
    Do u have any idea how to solve this out?

    Thanks again

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Maybe just dealing with the XML makes flash freeze.
    Is is a lot of data?
    Flash's performance was greatly improved in MX and it's even better in MX 2004, but it's not perfect yet.

    Maybe you get better help in the xml forum...

  5. #5
    Member
    Join Date
    Jan 2004
    Posts
    87
    The xml is not big but is put on stage when i have an animation, and for a sec or less the animation is not smooth.

    Thanks again for u help.

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