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

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

For performance testing, I wanted to try and move it to Amazon S3 hosting (which I already did with certain videos and large files).

I went ahead and did it, and updated the html page to link to 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 downloaded from a remote site (where they do not exist).

There are two obvious things that I could do: * copy all my resources remotely (not ready for this, as I'm just testing now) * add some abstraction to some URL address that .swf is accessing in some layer to get new way.

I really want to flip the switch and say: "Download everything regarding [the source server]."

Is there such a thing or am I downloading every download from a remote machine if I do not fully qualify each path?

I want to avoid something of a β€œhacked” type: subclass Image and hack the way there

+4
source share
2 answers

Add a slash in front of your urls, this should refer to the domain instead of the current folder:

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

This is a bit quick and dirty, submitting a "relative" url via a querystring ( or base parameter ) will be more flexible.

+1
source

You can try to specify the base parameter of your embed / object SWF tags. Theoretically, it defines the base path that will be used to resolve relative paths for loading, but I don’t know if it will work if the base value points to another server where the SWF is from.

See the documentation for embed / object parameters here . Scroll down to " base " in the middle.

If this does not work, another thing I have seen is passing to the user base path via flashvars . Then inside your SWF, you check to see if this base path is specified, and if so, add it to the relative URLs before downloading.

0
source

All Articles