Jump to content
Search Community

Loading from sub directories that reference relative paths

martis test
Moderator Tag

Recommended Posts

Hey guys,

 

Not sure if LoaderMax can handle this or not but here is my situation.

 

My main SWF is in the root directory. (Main.swf)

 

I am loading SWFs from root/resources/assets (Loaded.swf)

 

The SWFs that are being loaded are trying to load assets from a relative /resources folder (root/resources/assets/resources)

 

My problem is that when I load the SWFs into the main SWF in the root folder, it now looks at root/resources for those other assets, not root/resources/assets/resources.

 

My ideal solution would be to not have to edit the SWFs that I am loading in as a third party is producing them.

 

Is there anyway to somehow give the SWF context to its root directory when I load it in so it works?

 

EDIT: The experience is running in the standalone player, not the web

 

Found a solution, but it requires me to make edits to the SWFs that are being loaded in:

public static function getFullPath($loaderInfo:LoaderInfo):String 
{ 
    var myAbsolutePath:String; 
    var myRelativePath:String; 
     
    myAbsolutePath:String = $loaderInfo.url; 
     
    var stringStart:Number = 0; 
    var stringEnd:Number = myAbsolutePath.lastIndexOf("/")+1; 
     
    myRelativePath = myAbsolutePath.slice(stringStart, stringEnd); 
     
    return myRelativePath; 
}  

Thanks,

James 

Link to comment
Share on other sites

I've lived through this nightmare many times, years ago. Unfortunately, I don't remember any specifics about what I used other than possibly writing the code in the child swfs to detect whether or not they were loaded into a parent, and if so, adjust the urls accordingly. This helped when I wanted to test the child swfs on their own (without relying on them being in a container or parent). 

 

It seems like your solution is good to go. I'm very doubtful there is a solution that doesn't involve rewriting a little code in the child swfs. 

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