Jump to content
GreenSock

friendlygiraffe

Multiple XML Asset loaders

Recommended Posts

Is it possible to reference a loader asset by node ?

 

For example, I have a few VideoLoader, in XML, but I want to reference them via XML:

 

<?xml version="1.0" encoding="UTF-8"?>
<root>
 <car>
  <title>item 1</title>
  <VideoLoader name="video" url="car1.mp4" bufferMode="true" load="true" />
  <ImageLoader name="img" url="car1.jpg" load="true" />
 </car>
 <car>
  <title>item 2</title>
  <VideoLoader name="video" url="car2.mp4" bufferMode="true" load="true" />
  <ImageLoader name="img" url="car2.jpg" load="true" />
 </car>
 <car>
  <title>item 3</title>
  <VideoLoader name="video" url="car3.mp4" bufferMode="true" load="true" />
  <ImageLoader name="img" url="car3.jpg" load="true" />
 </car>
 <car>
  <title>item 4</title>
  <VideoLoader name="video" url="car4.mp4" bufferMode="true" load="true" />
  <ImageLoader name="img" url="car4.jpg" load="true" />
 </car>
 <car>
  <title>item 5</title>
  <VideoLoader name="video" url="car5.mp4" bufferMode="true" load="true" />
  <ImageLoader name="img" url="car5.jpg" load="true" />
 </car>
</root>

 

I want to be able to get the loader by doing something like:

 

var video:VideoLoader = LoaderMax.getLoader(xml.car[2].VideoLoader);
addChild(video.content);

 

Is this possible ?

Link to comment
Share on other sites

Yes, getLoader() accepts a name or url to find the proper loader.

All you would need to do is find the value of the @url attribute in the VideoLoader XML node that you want and pass that into getLoader() like:

 

var video:VideoLoader = LoaderMax.getLoader(xml.car[2].VideoLoader.@url);

 

make sense?

 

Also, you have a name attribute too in the xml which should work as well.

 

-c

Link to comment
Share on other sites

Yes, getLoader() accepts a name or url to find the proper loader.

All you would need to do is find the value of the @url attribute in the VideoLoader XML node that you want and pass that into getLoader() like:

 

var video:VideoLoader = LoaderMax.getLoader(xml.car[2].VideoLoader.@url);

 

make sense?

 

Also, you have a name attribute too in the xml which should work as well.

 

-c

That's exactly what I was looking for. Thanks

 

Is it also possible to attach properties after it has been loaded? eg: scaleMode, centerRegistration, bufferMode etc...

 

I'm trying this, but it seems to not have an affect:

 

var video:VideoLoader = LoaderMax.getLoader(Main.myXML.cars.car[num].VideoLoader.@url);
video.content.centerRegistration = true;
video.bufferMode = true;
video.content.scaleMode = "proportionalInside";
addChild(video.content);

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