multiversioned sub application asset paths in flex 4

142 Views Asked by At

Hopefully someone can help here, more or less looking for a) solution to relative paths or b) insight on another method of loading assets.

We have a standalone web application that is using SDK 4.1 and looks in its relative assets folder for all images and external swfs to be loaded.

on the server, this is the absolute path of the assets directory:

/ApplicationRoot/versionFldr/controls/assets/*

the application uses relative paths in all cases of loading an asset.. and this is continously being added to and updated as we advance versions of the app.

So, in essence, the app is looking for:

assets/*

now forward to the NEW application, lets call it "ParentApp" and the above application "ChildApp".

Parent App is in a different server directory than ChildApp

/ParentApp/version/controls/ParentApp.swf
/ChildApp/version/controls/ChildApp.swf

now, when ChildApp loads into ParentApp, it assumes that it is in the same directory that it's always been in. So, it looks for assets/* and cant find them because

/ParentApp/version/controls/assets/* != /ChildApp/version/controls/assets/*

I need to find a solution to have ChildApp look in an absolute path for ALL loaded assets when it is a child of ParentApp and have it look in paths relative to itself when it is standalone.

The caveats I have are that images are loaded into various controls, caches, and even mx:Text fields (html text with tags). I'm trying to avoid having to globally replace all path links across the application and having to create new coding procedures when new assets are created for the app. ChildApp is in production and has to stay on the 4.1 SDK.

ParentApp is new and has much more flexibility.

I've tried -source-path and -library-path compiler options in childApp, but this lead to compile errors and I have not been able to proceed.

Thank you in advance for any insight and help! -AJ

1

There are 1 best solutions below

2
On

I would solve this by having a "baseURL" variable in the child app. Give it a default value so that you can form the usual relative URL's that you are using: `var baseURL:String = "/assets/";

Unfortunately, you then have to modify every asset path in the child app so the path to the assets is something like: baseURL + assetFileName

When the child app is loaded into the parent app, you then give this baseURL variable a non-relative path. Ideally, you do that early in the process, before the child app tries to load any assets.