A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: XML not working after publish (but OK in preview)

  1. #1
    Member
    Join Date
    May 2007
    Posts
    55

    XML not working after publish (but OK in preview)

    Fundamentally my code seems to work on preview but when I actually publish nothing appears.
    Here's the code in full:

    Code:
    stop();
    
    #include "as/tween.as"
    var k:Number;
    
    var my_xml = new XML();
    my_xml.load("/xml/master.xml");
    my_xml.ignoreWhite = true;
    my_xml.onLoad = function(success) {
     if (success) {
      for (var i = 0; i<10; i++) {
       var populate = my_xml.firstChild.childNodes[i].firstChild;
       k = (i+1);
       _root['tc'+i]._alpha = 0;
       fill(_root['tc'+i],k);
      }
      var q0 = my_xml.firstChild.childNodes[0].firstChild;
      var q1 = my_xml.firstChild.childNodes[1].firstChild;
      var q2 = my_xml.firstChild.childNodes[2].firstChild;
      var q3 = my_xml.firstChild.childNodes[3].firstChild;
      var q4 = my_xml.firstChild.childNodes[4].firstChild;
      var q5 = my_xml.firstChild.childNodes[5].firstChild;
      var q6 = my_xml.firstChild.childNodes[6].firstChild;
      var q7 = my_xml.firstChild.childNodes[7].firstChild;
      var q8 = my_xml.firstChild.childNodes[8].firstChild;
      var q9 = my_xml.firstChild.childNodes[9].firstChild;
    
      _root.tc0.txt1.text = q0;
      _root.tc1.txt1.text = q1;
      _root.tc2.txt1.text = q2;
      _root.tc3.txt1.text = q3;
      _root.tc4.txt1.text = q4;
      _root.tc5.txt1.text = q5;
      _root.tc6.txt1.text = q6;
      _root.tc7.txt1.text = q7;
    
      _root.inv1.onRelease = function() {
       if (_root['tc6']._alpha>99) {
        init();
       } else {
        fader(_root['tc0'],0,100,3);
       }
    
      };
     }
    };
    function init() {
     for (var j = 0; j<10; j++) {
      _root['tc'+j]._alpha = 0;
      _root['tc'+j]._visible = false;
     }
     _root.inv1.onRelease = function() {
      _root['tc0']._visible = true;
      if (_root['tc6']._alpha>99) {
       init();
      } else {
       fader(_root['tc0'],0,100,3);
      }
    
     };
    }
    function fill(mc, k) {
     mc.onRelease = function() {
      _root['tc'+k]._visible = true;
      trace(_root['tc'+k]);
      if (_root['tc'+k]._alpha<99) {
       fader(_root['tc'+k],0,100,3);
      }
     };
    }
    The XML is just a list with test phrases which, as I said, appear quite correctly in the dynamic text fields (inside the mcs, tc0, tc1, tc2 etc)

    The XML file is located in the folder /xml/ one level above the swf folder.

    What puzzles me is that everything seems OK on using shift>enter to preview and yet it doesn't work after publishing.

    Anyone got any ideas?

  2. #2
    Member
    Join Date
    May 2007
    Posts
    55

    Problem solved - sorry for time wasting...

    problem solved - I had an extra slash in the code:

    my_xml.load("/xml/master.xml");

    should have read:

    my_xml.load("xml/master.xml");

    doh!

Tags for this Thread

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