Jump to content
GreenSock

friendlygiraffe

prependURLs

Recommended Posts

hi - I only want prependURLs on one loader. 'images'.

 

The problem is, the prependURL is set using a FlashVar. So I wouldn't be able to hard code it in the XML. What I'm trying to do is load it all, and then set the prependURLs property after it's loaded. Would I have to separate the XML into 2 documents ?

 

here is my XML:

 

<?xml version="1.0" encoding="UTF-8"?>
<root>
<LoaderMax name="feeds" load="true">
 <XMLLoader estimatedBytes="20000" name="main" url="http://news.mercedes-benz.co.uk/category/fleet_and_business/feed" />
</LoaderMax>
<LoaderMax name="images" load="true" >
 <ImageLoader name="avatar_twitter" url="images/icon_twitter.png" estimatedBytes="2000" />
 <ImageLoader name="icon_facebook" url="images/icon_facebook.png" estimatedBytes="2000" />
 <ImageLoader name="icon_twitter" url="images/icon_twitter.png" estimatedBytes="2000" />
 <ImageLoader name="icon_feed" url="images/icon_feed.png" estimatedBytes="2000"/>
</LoaderMax>
</root>

Link to comment
Share on other sites

You have 2 options:

 

1) Use an onRawLoad to call a function when only the XML has loaded (but hasn't been fully parsed by LoaderMax) and then inject any changes to your XML at that point so that you insert your prependURLs directly into the XML. That way, when LoaderMax parses it, it acts as though it was always there to begin with. And to reference the XML, just use the "content" of the XMLLoader.

 

2) Remove load="true" from your images LoaderMax XML, and then simply wait for your XML to load (use an onComplete), and then use getLoader() to get your "images" LoaderMax instance and apply a prependURLs() there. Like:

 

var images:LoaderMax = LoaderMax.getLoader("images") as LoaderMax;
images.prependURLs("blah_blah_blah");
images.addEventListener(LoaderEvent.COMPLETE, completeHandler);
images.load();

function completeHandler(event:LoaderEvent):void {
trace("images loaded.");
}

Link to comment
Share on other sites

Thanks I tried that actually, I also set :

<LoaderMax name="images" load="true" >

But there seemed no way of doing it, without creating 2 separate loaders. I have to wait for the first loader to finish loading the XML before I create a 2nd loader. There doesn't seem to be a way to integrate the progress of everything?

Link to comment
Share on other sites

Did you try my first recommendation?

 

Use an onRawLoad to call a function when only the XML has loaded (but hasn't been fully parsed by LoaderMax) and then inject any changes to your XML at that point so that you insert your prependURLs directly into the XML. That way, when LoaderMax parses it, it acts as though it was always there to begin with. And to reference the XML, just use the "content" of the XMLLoader.
Link to comment
Share on other sites

I didn't actually. I just tried it now. I seems to work using this function. The rawHandler fired several times so I checked if it already existed. I also set load="false" in the XML:

 

 private function rawHandler(e:LoaderEvent):void
 {
  if (icons == null && LoaderMax.getLoader("images"))
  {
   icons = LoaderMax.getLoader("images") as LoaderMax;
   icons.prependURLs("blah blah blah");
   icons.load();
  }
 }

 

Thanks a lot

Link to comment
Share on other sites

Glad to hear you got it working.

 

Are you saying that the same onRawLoad gets fired multiple times from the same XMLLoader on a single load? If so, could you post a very simple FLA (and support files) that we can publish on our end to see the behavior?

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