Jump to content
Search Community

get Child XML

friendlygiraffe test
Moderator Tag

Recommended Posts

is it possible to return a LoaderMax's XML ?

Here is my XML:

 

<LoaderMax name="article1" load="true">
 <ImageLoader name="thumb" url="images/page1.jpg" estimatedBytes="2000" load="true" />
 <ImageLoader name="page" url="images/page1.jpg" estimatedBytes="2000" />
 <title>
  Article title 1
 </title>
 <button>
  Click here to find out more
 </button>
</LoaderMax>

 

i want return <title>, <button> etc.. by using LoaderMax.getLoader('article1').button;

Link to comment
Share on other sites

yes, each Loader (in this case your LoaderMax) has a rawXML property attached to its vars making it easy to attach additional xml-formatted data to any loader. You can read more in the XMLLoader docs.

 

the following code will get the <button> text from your xml:

 

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

var article1AsXML:XML;

var xml:XMLLoader = new XMLLoader("data.xml", {onComplete:completeHandler});

xml.load();

function completeHandler(e:LoaderEvent):void{
trace("xml done loading");
article1AsXML = LoaderMax.getLoader('article1').vars.rawXML
trace(article1AsXML.button); // output: Click here to find out more
}

  • Like 1
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...