Jump to content
Search Community

XMLLoader only loading the first line..!

SudoPlz test
Moderator Tag

Recommended Posts

 xmlLoader = new LoaderMax({name:"aName", autoDispose :true, onComplete:propsLoaded});
        xmlLoader.append(new XMLLoader(curTaleDirectory+ "/" +Constants.PROPS_XML_FILENAME, {name:"anotherName"+_taleId.toString() , autoDispose :true,  estimatedBytes:841 }));
        xmlLoader.load();


private function propsLoaded(e:LoaderEvent):void {

        var objects:Array = e.currentTarget.content;
        var taleProps:XML = objects[0];     // This ONLY works on mobile devices..!
        //TODO: Why doesnt it recognise the WHOLE file?
        trace(taleProps); // prints this: <?xml version="1.0" encoding="utf-8"?> 
}
<?xml version="1.0" encoding="utf-8"?>
<tale id="1">
  <page id="1">
    <taleText>
Lorem ipsum bla bla
    </taleText>
    <LoaderMax name="ft$1:page$1">
      <MP3Loader name="ft$1:page$1:mc$1$always" url="page_1/backsound.mp3" estimatedBytes:"2050" autoPlay="false" />
      <MP3Loader name="ft$1:page$1:mc$1$onClick" url="page_1/backsound.mp3" estimatedBytes:"2050" autoPlay="false" />
    </LoaderMax>
  </page>
  <page id="2">
    
  </page>
  <page id="3">
   
  </page>
  <page id="4">
   
  </page>
  <page id="5">
   
  </page>
  
  <name>aName</name>
  <purchased>true</purchased>
  <pageCnt>20</pageCnt>
  <url></url>
</tale>

I'm using the code above to load the above xml file.. Instead of getting the whole file loaded, I only get the first line.. Why is that?

 

Thank you.!

Link to comment
Share on other sites

Hmmm, I'd make sure that your xml isn't malformed or contains any weird hidden characters.

 

I used similar code to your example and created an xml-file with the data above and was getting errors basically saying that the loaded content could not be converted to xml. 

 

Your ActionScript looks fine.

I simplified the XML and didn't get any errors.

 

my AS:

import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;


LoaderMax.activate([XMLLoader]);


var xmlLoader = new LoaderMax({name:"aName", autoDispose :true, onComplete:propsLoaded});
        xmlLoader.append(new XMLLoader("data.xml", {name:"anotherName", autoDispose :true,  estimatedBytes:841 }));
        xmlLoader.load();




function propsLoaded(e:LoaderEvent):void {
  var objects:Array = e.currentTarget.content;
var taleProps:XML = objects[0]; 
    trace(taleProps); // no errors, shows full xml
}

my XML

 

<?xml version="1.0" encoding="utf-8"?>
<data>
<asset name="fred"></asset>
<asset name="fred"></asset>
<asset name="fred"></asset>
<asset name="fred">
<img url="fred.jp"></img>
</asset>
</data>

I attached my fla and xml

 

 

 

xmlTest_CS5.zip

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...