dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: preloading Multiple XML Docs (HELP PLEASE)

  1. #1
    Junior Member
    Join Date
    Oct 2000
    Posts
    6
    Ok guys...now I have no XML experience and am thick as hell so please bare with me....the following script works fine locally but grinds to a halt when run on a server. I am basically trying to load 4 xml docs, parse them and spit them out as 4 variables which I can laod from a SWF in a different level.

    Basically I need someones help to help me get the damn thing to work on a server. I think the problem is is with checking wether or not the xml files have loaded or not. But my limited skills prevent me solving this wredched problem..

    please please please if any one can help I would greatly appreciate it.

    Here is the code on 1 frame so far. (Works fine locally but not on the server)

    ----------------------------------
    Object.version = getVersion().split(",");
    Object.majorVersion = int(substring(Object.version[0],Object.version[0].length, 1));
    Object.minorVersion = int(Object.version[2]);

    function XMLnitro(){
    superClass();
    }
    if (Object.majorVersion == 5){
    XMLnitro.prototype.parseXML = function(str){
    var treePtr = this;
    var tags = new Array();
    var textNode = null;
    if (Object.minorVersion == 30){
    this.status = ASnative(300, 0)(str, tags);
    }else{
    this.status = ASnative(300, 0)(str, tags, false);
    }
    if (this.status == 0){
    var curr;
    var i=0;
    var max = tags.length;
    if (this.ignoreWhite){
    while(tags[i].type == 3){
    ++i;
    }
    while (i<max){
    curr = tags[i];
    if (curr.type == 1){
    if (curr.value == "/"+treePtr.nodeName){
    if (textNode != null){
    if (treePtr.firstChild == null){
    treePtr.appendChild(this.createTextNode(textNode)) ;
    }
    textNode = null;
    }
    treePtr = treePtr.parentNode;
    }else{
    treePtr.appendChild(this.createElement(curr.value) );
    treePtr = treePtr.lastChild;
    treePtr.attributes = curr.attrs;
    if (curr.empty){
    treePtr = treePtr.parentNode;
    }
    textNode = null;
    }
    }else{
    if (curr.type == 3 || curr.type == 6){
    textNode = curr.value;
    }else{
    if (curr.type == 4){
    this.xmlDecl = curr.value;
    }else{
    this.docTypeDecl = curr.value;
    }
    }
    }
    ++i;
    }
    }else{
    while (i<max){
    curr = tags[i];
    if (curr.type == 1){
    if (curr.value == "/"+treePtr.nodeName){
    treePtr = treePtr.parentNode;
    }else{
    treePtr.appendChild(this.createElement(curr.value) );
    treePtr = treePtr.lastChild;
    treePtr.attributes = curr.attrs;
    if (curr.empty){
    treePtr = treePtr.parentNode;
    }
    }
    }else{
    if (curr.type == 3 || curr.type == 6){
    treePtr.appendChild(this.createTextNode(curr.value ));
    }else{
    if (curr.type == 4){
    this.xmlDecl = curr.value;
    }else{
    this.docTypeDecl = curr.value;
    }
    }
    }
    ++i;
    }
    }
    }
    }
    }
    XMLnitro.prototype.__proto__ = XML.prototype;
    XMLnitro.prototype.superClass = XML.prototype.constructor;
    /******************************
    News Functions !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
    *******************************/
    function initNews(){
    NewsOutput = "Loading XML Data...";
    NewsXMLSrc = "http://www.adamf.com/ms//publicsites/adamf/news/?view=xml";
    }
    function initBio(){
    NewsOutput = "Loading XML Data...";
    BioXMLSrc = "http://www.adamf.com/ms//publicsites/adamf/biography/?view=xml";
    }
    function initTours(){
    NewsOutput = "Loading XML Data...";
    ToursXMLSrc = "http://www.adamf.com/ms//publicsites/adamf/tours/?view=xml";
    }
    function initDisco(){
    NewsOutput = "Loading XML Data...";
    DiscoXMLSrc = "http://www.adamf.com/ms//publicsites/adamf/discography/?view=xml";
    }
    function NewsaddHeadline(news_title,news_display_date,news_ teaser,news_text){
    NewsOutput = ""
    NewsOutput += "<font color=\"#FF9900\" size=\"10\">"+news_title+"</font><br><font color=\"#FFCC00\" size=\"10\">"+news_display_date+"</FONT><br>";
    NewsOutput += news_text+"<br><br>";
    }
    function BioaddHeadline(biography_artist_name,biography_tit le,biography_text){
    BioOutput = ""
    BioOutput += "<font color=\"#FF9900\" size=\"10\">"+biography_artist_name+"</font><br><font color=\"#FFCC00\" size=\"10\">"+biography_title+"</FONT><br>";
    BioOutput += biography_text+"<br><br>";
    }
    function ToursaddHeadline(tours_venue,tours_town,tours_stat us,tours_show_date,tours_info){
    ToursOutput = ""
    ToursOutput += "<font color=\"#FF9900\" size=\"10\">"+tours_venue+"</font><br><font color=\"#FFCC00\" size=\"10\">"+tours_show_date+"</FONT><br>";
    ToursOutput += tours_status+"<br>"+tours_info+"<br><br>";
    }
    function DiscoaddHeadline(discography_title,discography_art ist_name,discography_disc_type,discography_catalog ue_number,discography_catalogue_text,discography_t rack_text,discography_note_text,discography_releas e_date,discography_display_date){
    DiscosOutput = ""
    DiscoOutput += "<font color=\"#FF9900\" size=\"10\">"+discography_title+"</font><br><font color=\"#FFCC00\" size=\"10\">"+discography_artist_name+"</FONT><br>";
    DiscoOutput += discography_disc_type+discography_catalogue_number +"<br>"+discography_release_date+"<br>"+discograph y_note_text+"<br><br>"+discography_track_text;
    }
    function onLoadNews( success ){
    if( success ){
    this = this.firstChild;
    if(this.nodeName == null){
    this = this.nextSibling;
    }
    var kids = this.childNodes;
    for(var i=0;i<kids.length;i++){
    if(kids[i].nodeName == "news_entry"){
    var kids2 = kids[i].childNodes;
    for(var j=0;j<kids2.length;j++){
    if(kids2[j].nodeName == "news_title"){
    news_title = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "news_display_date"){
    news_display_date = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "news_text"){
    news_text = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "news_teaser"){
    news_teaser = kids2[j].firstChild.NodeValue;
    }
    }
    NewsaddHeadline(news_title,news_display_date,news_ teaser,news_text);
    }
    }
    }
    }

    function onLoadBio( success ){
    if( success ){
    this = this.firstChild;
    if(this.nodeName == null){
    this = this.nextSibling;
    }
    var kids = this.childNodes;

    for(var i=0;i<kids.length;i++){
    if(kids[i].nodeName == "biography_entry"){
    var kids2 = kids[i].childNodes;
    for(var j=0;j<kids2.length;j++){
    if(kids2[j].nodeName == "biography_artist_name"){
    biography_artist_name = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "biography_title"){
    biography_title = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "biography_text"){
    biography_text = kids2[j].firstChild.NodeValue;
    }
    }
    BioaddHeadline(biography_artist_name,biography_tit le,biography_text);
    }

    }
    }
    }
    function onLoadTours( success ){
    if( success ){
    this = this.firstChild;
    if(this.nodeName == null){
    this = this.nextSibling;
    }
    var kids = this.childNodes;
    for(var i=0;i<kids.length;i++){
    if(kids[i].nodeName == "tours_entry"){
    var kids2 = kids[i].childNodes;
    for(var j=0;j<kids2.length;j++){
    if(kids2[j].nodeName == "tours_venue"){
    tours_venue = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "tours_town"){
    tours_town = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "tours_status"){
    tours_status = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "tours_show_date"){
    tours_show_date = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "tours_info"){
    tours_info = kids2[j].firstChild.NodeValue;
    }
    }
    ToursaddHeadline(tours_venue,tours_town,tours_stat us,tours_show_date,tours_info);
    }
    }
    }
    }
    function onLoadDisco( success ){

    if( success ){

    this = this.firstChild;
    if(this.nodeName == null){
    this = this.nextSibling;
    }
    var kids = this.childNodes;
    for(var i=0;i<kids.length;i++){
    if(kids[i].nodeName == "discography_entry"){
    var kids2 = kids[i].childNodes;
    for(var j=0;j<kids2.length;j++){
    if(kids2[j].nodeName == "discography_title"){
    discography_title = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "discography_artist_name"){
    discography_artist_name = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "discography_disc_type"){
    discography_disc_type = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "discography_catalogue_number"){
    discography_catalogue_number = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "discography_catalogue_text"){
    discography_catalogue_text = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "discography_track_text"){
    discography_track_text = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "discography_note_text"){
    discography_note_text = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "discography_release_date"){
    discography_release_date = kids2[j].firstChild.NodeValue;
    }
    if(kids2[j].nodeName == "discography_display_date"){
    discography_display_date = kids2[j].firstChild.NodeValue;
    }
    }
    DiscoaddHeadline(discography_title,discography_art ist_name,discography_disc_type,discography_catalog ue_number,discography_catalogue_text,discography_t rack_text,discography_note_text,discography_releas e_date,discography_display_date);
    }
    }
    }
    }


    function initALL(){

    initTours();
    initNews();
    initBio();
    initDisco();

    myXMLTours = new XMLnitro();
    myXMLNews = new XMLnitro();
    myXMLBio = new XMLnitro();
    myXMLDisco = new XMLnitro();

    myXMLTours.load(ToursXMLSrc);
    myXMLNews.load(NewsXMLSrc);
    myXMLBio.load(BioXMLSrc);
    myXMLDisco.load(DiscoXMLSrc);

    myXMLTours.onLoad = onLoadTours;
    myXMLNews.onLoad = onLoadNews;
    myXMLBio.onLoad = onLoadBio;
    myXMLDisco.onLoad = onLoadDisco;


    myXMLTours.ignoreWhite = true;
    myXMLNews.ignoreWhite = true;
    myXMLBio.ignoreWhite = true;
    myXMLDisco.ignoreWhite = true;

    }

    initALL();

    Thanx for any help guys...

  2. #2
    Senior Member
    Join Date
    Nov 2000
    Posts
    275
    Hi Ant,

    I know you through chatting to Brendan, Hoss & Pete. I have been editing your code and am afraid to say it needs quite a bit of TLC before its gonna do what you want. There are a few loops not finished off yet, the concatenation of the output needs a look at and some other bits. If you still need some help with it, email me. Maybe I can help you out.

    Cheers,

  3. #3
    loading multiple xml documents in the same frame is a reipy for disaster. I've not the patience of developette to read through all that code (a bit excessive perhaps??), but do know there can be big time problems with loading more than one xml per frame.

    Try loading one document per frame, with an myXML.onLoad.gotoAndPlay(nextframe) or two.

    Even that's not a gaurenteed fix - xml is a bit new in FLASH 5, and whilst its a huge advance having it at all, true easy and robust functionality is coming in v6 (or so I hear)

    best of luck!

    RT

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