Jump to content
Search Community

recursivePrependURLs is not working for me

dorkbot test
Moderator Tag

Recommended Posts

Hi,


 


I can't get recursivePrependURLs to work for me. I have additional XMLLoaders in an xml file I'm loading. The main xml file is getting loaded but none of its children are, their URLs are not being updated.


 


var relativePath:String = "/";


 


LoaderMax.activate([xmlLoader]);


var queue:LoaderMax = new LoaderMax({name:"mainQueue", onComplete:loadFilesComplete});


var xmlLoader:XMLLoader = new XMLLoader("assets/xml/config.xml", newXMLLoaderVars().name("configXML").recursivePrependURLs(relativePath));


queue.append( xmlLoader );


queue.prependURLs(relativePath);


queue.load();


 


and here is my xml:


<config>

<settings stageWidth="800" stageHeight="600" />

<XMLLoader name="tips and hints XML" url="assets/xml/tips_and_hints.xml" load="true" estimatedBytes="10" />

<XMLLoader name="items" url="assets/xml/items.xml" load="true" estimatedBytes="10" />

<XMLLoader name="careers" url="assets/xml/careers.xml" load="true" estimatedBytes="10" />

<XMLLoader name="origin comic" url="assets/xml/origin-comic.xml" load="true" estimatedBytes="10" />

</config>

 

Am I doing something wrong?

 

Cheers

Link to comment
Share on other sites

I made a very simple test trying to replicate your setup as close as possible and had no errors. I've attached my fla and 2 xml files.

 

config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
<settings stageWidth="800" stageHeight="600" />
<XMLLoader name="tips and hints XML" url="xml/tips_and_hints.xml" load="true" estimatedBytes="10" />
</config>
 
tips_and_hints.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<person name="carl"></person>
</config>

 

both files live in dummy/xml

 

I am using recursivePrependURLs to add "dummy/" to the url of the XMLoader that loads config.xml AND the XMLLoader node in config.xml that is used to load tips_and_hints.xml

 

The following AS code executes with no errors:

 

import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.data.XMLLoaderVars;
import flash.display.Loader;


LoaderMax.activate([XMLLoader]);


var relativePath:String = "dummy/";




var queue:LoaderMax = new LoaderMax({name:"mainQueue", onComplete:loadFilesComplete});
var xmlLoader:XMLLoader = new XMLLoader("xml/config.xml", new XMLLoaderVars().name("configXML").recursivePrependURLs(relativePath).onChildComplete(xmlComplete).onComplete(xmlComplete));
queue.append( xmlLoader );
queue.prependURLs(relativePath);
queue.load();


function xmlComplete(e:LoaderEvent):void {
trace(e.target.content);
}


function loadFilesComplete(e:LoaderEvent): void {
trace("loadFilesComplete()");
}

I get traces of the contents of both xml files.

 

If you still have trouble please provide a similar simple set of files that exhibits the problem you are having.

 

recursiveUrls_CS5.zip

Link to comment
Share on other sites

Hi, 


 


I'll try to build a test when I have time. But here is more detail. I was able to fix my issue by using ActionScript 3's loader class. 


 


I have a swf that loads another swf that loads another swf.


 


Swf A loads swf B, swf B loads swf C.


 


Swf B also loads xml.


 


Swf B works fine when played alone. 


 


 


In swf B I'm getting its relative URL so its assets will load. I'm using this code to get the relative path so swf B will function inside swf A or when played standalone:


 


var obsolutePath:String; 


var relativePath:String; 


 


obsolutePath = loaderInfo.url; 


 


var stringStart:Number = 0; 


var stringEnd:Number = obsolutePath.lastIndexOf("/")+1; 


 


relativePath = obsolutePath.slice(stringStart, stringEnd); 


 


 


 


When swf B loads into swf A I get a LoaderMax error stating that swf A couldn't load swf B, and the url the message displays has is showing the url being set by swf B, it's very odd. So swf B sets its relative url, and swf A sets its relative url, and swf B is overriding swf A's relative url.


 


 


I fixed it buy using this in swf A for loading swf B:


 


var appDomain:ApplicationDomain = new ApplicationDomain(); 


var context:LoaderContext = new LoaderContext(false, appDomain);


 


var loader:Loader = new Loader(); 


var req:URLRequest = new URLRequest(DataVO( facade.retrieveProxy( DataProxy.NAME ).getData() ).relativePath + "career-home-swf/b.swf"); 


 


loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler); 


loader.load(req, context);


 


 


 


swf B and swf A are two different projects in Flash Builder, but they have many of the same frameworks. They don't share literally the same files, they have copies of the same frameworks. swf C only has art assets, no added classes or code.


 


Is my issue related to this: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e07.html


 


 


Thanks for any help or explanation.


 


Cheers.


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