Jump to content
Search Community

Nested XML Structure

justignite test
Moderator Tag

Recommended Posts

Hello. I am new to LoaderMax and I am planning to shift to this library for my next project.

 

I am trying to make another version for my old project which uses nested xml structure. My purpose is to make a "back loading" function. Yes, my old project has a back button and it will go through the xml. My xml structure is something like this:

 

<page name="main">
<page>
 <page>
  <page></page>
  <page></page>
  <page></page>
  <page></page>
 </page>
</page>
<page></page>
<page></page>
<page></page>
</page>

 

My back button function will load the parent of the child node. It works great but my question is how can I possible make the same structure in LoaderMax. I tried using XMLLoader for that and my structure is this:

 

<page name="BundleBee" tagline="">
<SWFLoader name="main" url="assets/games/main.swf" estimatedBytes="3300" load="true" title="This is a title">
 <SWFLoader name="game1" url="assets/games/game1.swf" estimatedBytes="3300" load="true"></SWFLoader>
 <SWFLoader name="game2" url="assets/games/game1.swf" estimatedBytes="3300" load="true"></SWFLoader>
</SWFLoader>
<SWFLoader name="main2" url="assets/games/main.swf" estimatedBytes="3300" load="true" title="This is a title">
</SWFLoader>
</page>

 

I want to go through the nodes and get its attributes but i cant figure out how to do that in xmlloader, except to call the loader, LoaderMax.getLoader("main") / ("game1") / ("game2"). Is there another way to deal with this. Please tell me ways to deal with nested nodes and do back function in my app. I still cannot picture out.

 

 

I tried LoaderMax last night to get my hands dirty. Its really good and cool. ^_^

Link to comment
Share on other sites

Hi,

 

Glad to hear you are considering LoaderMax for your project and that you have been pleased so far. I think you will quickly find that it is super powerful and flexible. With all the features it can take a little time to get fully comfortable with the API and often there are multiple ways to accomplish a task.

 

Instead of nesting SWFLoader nodes inside each other like you are doing in your xml I would suggest that you create a LoaderMax node for each main section

 

<page name="BundleBee" tagline=""">
<LoaderMax name ="main1" load="true" estimatedBytes="xxxxxxx">
<SWFLoader name="main" url="assets/games/main.swf" estimatedBytes="3300" load="true" title="This is a title" />
<SWFLoader name="game1" url="assets/games/game1.swf" estimatedBytes="3300" load="true" />
<SWFLoader name="game2" url="assets/games/game2.swf" estimatedBytes="3300" load="true" />
</LoaderMax>
</page>

 

 

So basically that LoaderMax node lists all the SWFLoaders related to that section of your site.

You can then use LoaderMax's getChildren() method to get an array of all the loaders.

 

Your navigation buttons can then use methods like

getChildAt() to get the next or previous SWFLoader.

 

In essence you could keep track of the index of the currently loaded swf

 

currentSWFIndex = 2;

//code inside next button event handler:
currentSWFIndex++
mainSectionloaderMax.getChildAt(currentSWFIndex).load();

 

Of course you would also check to see if currenSWFIndex++ was within the range of items inside the LoaderMax.

 

Also you can figure out the index of a particular loader with getChildIndex()

 

In my rough code above your LoaderMax contains 3 swfs. The first swf assets/games/main.swf would have an index of 0, so you would probably only navigate between loaders with the indexes of 1 and 2. You can also nest LoaderMaxes inside LoaderMaxes if you want your game swfs to be in their own LoaderMax queue/list than their respective "main" swf.

 

Hopefully this is enough info to get you on your way in a feasible direction.

I would suggest starting real small with just a few swfs and try to maximize the LoaderMax API to target and control each of the assets.

 

Let us know if you need more help.

Link to comment
Share on other sites

Thanks for a detailed explanation. I think this getChildAt() will greatly help. But still something is bugging me. What if I will have this kind of xml structure? Coz this structure is what I am trying to achieve.... 3 to 4 depths.

 

<page name="main">
<page>
 <page>
  <page>
    <page></page>
    <page>
		    <page></page>
		    <page></page>
    </page>
    <page></page>
    <page></page>
  </page>
  <page></page>
  <page></page>
  <page></page>
 </page>
</page>
<page></page>
<page></page>
<page></page>
</page>

 

 

Based on what you stated, I could have LoaderMax(s) inside a LoaderMax so my question is how can I get the loaders inside my second LoaderMax? using getChildAt()? how about if i have my own attributes like "title" and "description"?

 

I am still digging here, trying to familiarize this API with the more convenient way I could get. Btw, starting from now I will use this loading system instead Flash`s.

 

Sorry, English is not my first language. ^_^..

 

Thanks Carl.

Link to comment
Share on other sites

As for additional attributes like title and description, that data gets stored with each loader.

 

Take a look at the paragraph prior to the 3rd code sample here

http://www.greensock.com/as/docs/tween/com/greensock/loading/XMLLoader.html

 

It explains how additional attributes are stored in the loader's vars object.

 

---

 

how can I get the loaders inside my second LoaderMax? using getChildAt()?

 

Yes, with a structure that deeply nested, I imagine at some point you will have to recursively loop through the loaders you have and test each one to see if it is a LoaderMax and if so you will then loop through its children and run the same test.

 

Also, you can still access the xml you loaded and if you want you can still parse that xml to find loader names or urls and pass those values into LoaderMax.getLoader(someNameOrUrl) and then check their load status, load them, unload them or any number of things.

 

I understand these suggestions may sound a bit vague. You have quite a complex system there and although LoaderMax will certainly give you the hooks necessary to load, target and control your content, there isn't really a simple answer.

 

I would suggest you start with a real simple 2-level image gallery with only a handful of assets. It will make it much easier for us to offer actionable advice once some parts of it are working.

We'd love to see you have success with this project.

 

btw, your English is quite good!

Link to comment
Share on other sites

Yes, I am beginning to understand LoaderMax now with some experiments. I tried getLoader(name) and it works like charm.

 

I did some experiment using my own xml tagging + SWFLoader so I have to call it by nodes. It is good but I still want to find another way which is easier for me to expand my project. Anyway, looks like I am going to figure it out myself.

 

Ofcourse, I will share what I know and experience with this project. Hope it will be successful.

 

Thank you for your time and with this great enlightenment.

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...