R – Loading Flex resources relative to server root as opposed to .swf location

actionscriptapache-flexrelative-path

I have a large (700kb) Flex .swf file representing the main file of a site.

For performance testing I wanted to try and move it off to Amazon S3 hosting (which i have already done with certain videos and large files).

I went ahead and did that, and updated the html page to reference the remote .swf.

It turns out that Flash will load any resources relative to the .swf file accessing the resource – no matter what the root of the html page is. So my resources are now being loaded from the remote site (where they don't exist).

There are two obvious things I could do :
* copy all my resources remotely (not ready for this since i'm just testing now)
* add in some layer of abstraction to every URL that the .swf accesses to derive a new path.

I really want to flick a switch and say 'load everything relative to [original server]'.

Does such a thing exist or am I stuck loading everythin from the remote machine unless I fully qualify every path?

i want to avoid anything 'hacky' like : subclass Image and hack the path there

Best Answer

Append a slash before your urls, this should load relative to the domain instead of the current folder:

foo.load('/like/this/image.jpg')

This is a bit quick and dirty, feeding a "relative" url via a querystring (or the base parameter) would be way more flexible.

Related Topic