Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Sil3noz

xml with data and images

Recommended Posts

hello! :)

im just tryin to parse and get some data from an xml like that:

 

<?xml version="1.0" encoding="utf-8"?> 



This is the description for the image 1
This is the description for the image 1



This is the description for the image 2
This is the description for the image 2



This is the description for the image 3
This is the description for the image 3


 

No problem with the automatic ImageLoader parsing, just read and followed the examples, but how can i store or have access to the other node-data like desc or desc2?

thanks a lot in advance for any advice! :)

Link to comment
Share on other sites

XMLLoader's "content" property will refer to the actual XML that was loaded, so you can use that.

 

var loader:XMLLoader = new XMLLoader("data.xml", {name:"myXML", onComplete:completeHandler});
loader.load();
function completeHandler(event:LoaderEvent):void {
   var xml:XML = LoaderMax.getContent("myXML");
   trace(xml.slide[0].desc);
}

Link to comment
Share on other sites

  • 1 month later...

This is cool. What I'm not understanding is how to get the xml data into containers so I can control it?

 

The example makes so much sense:

queue.append( new ImageLoader("img/photo1.jpg", {name:"photo1", estimatedBytes:2400, container:this, alpha:0, width:250, height:150, scaleMode:"proportionalInside"}) );

However I need to bring in variables connected to images, so I'm thinking the xmlLoader is the best way to go, but then how do I parse the xml into MC containers ? The newImageLoader is way more simple/logical for me...

Link to comment
Share on other sites

There are several ways to accomplish this. Have you looked at the slideshow example source files that I recently uploaded? If not, check 'em out at http://www.greensock.com/as/LoaderMax/slideshow.zip (I'll leave the files there for at least another week). The slideshow has image data that is stored in XML and parsed in the app. I suspect this would answer some of your questions and help you along.

Link to comment
Share on other sites

Hey thanks! Awesome I'll take a look. Much appreciated!

Link to comment
Share on other sites

Hey thanks again this is making a lot of sense.

 

One thing tho, I've hithertofore ignored private + public and packages... I'm familiar with all the code inside those, but I get Super confused with all this package / public function / private function thing and using external .as files, can you point me in the right direction to figure this out? :) I'm kind of getting it, but... its complex.

 

Also, why is var curX called curX ? is it just a random name? or is there a reason to it? does cur mean something?

 

Thanks again so much!

Link to comment
Share on other sites

curX is just short for "current X" which is the value that keeps track of the thumbnail position as we iterate through the loop.

 

public and private variables just indicate their visibility to outside code. private variables can only be accessed inside the class. Public ones can be accessed by anywhere else (other classes, the main timeline, within the same class, whatever). Typically it's best to only expose variables as public if it's a necessary part of the API. Otherwise, make them private so that other classes can't mess with your stuff. I'd definitely recommend getting a good AS3 book because it'll walk you through all this type of stuff. (not that it's bad to ask here).

Link to comment
Share on other sites

Thanks so much, thats the clearest, shortest explanation so far ;) It's all becoming clearer!

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