• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Flash MX question

Upchurch

Papa Funkosophy
Joined
May 10, 2002
Messages
34,265
Location
St. Louis, MO
I'm using LoadVariables to pull in information from an .asp page that is in the web root, but my .swf is several directories down from the root. Does anyone know how I code the location of my .asp page without giving an absolute path name?

In otherwords, the I want it to always look towards the web root no matter what server it is on.

edited 'cause I'm a moron who can't differentiate "MX" from "XP". Too many dang X's
 
Use "../" to go back up the directory tree one level.

For example, if you're 3 directories down from the root, just repeat.
"../../../"
 
DOCUMENT_ROOT

The DOCUMENT_ROOT environment variable in IIS can also be used as an alias for the server root directory. (assuming Flash can access environment variables)

M
 
It's been about 2 years since I last ran flash, but it seems that the DOCUMENT_ROOT solution would do it.

The .asp file you are calling from LoadVariables could simply contain a line like:
root_path = DOCUMENT_ROOT
(I forget the .asp call)
Or you could hard-code the root in the .asp like:
root_path = "C:\IIS\SomeWeb\etc"

And then in Flash, on that level you would have a variable named 'root_path' and you are in business.
 
If relative paths aren't working for you. (I don't know why but they don't always seem to work in Flash...) Try flashvars method.

You define a param "flashvars" in your object and embed tags and it appears as a name-value pair in your SWF.


example:
PHP:
 <param flashvars="RootPath=http://my.server.com/wwwroot/">

Then you refer to that variable in your SWF as _root.RootPath.

In this way you can simply edit the path in the HTML file that calls the SWF when you change servers. There are other ways to do this, but I use mostly ColdFusion / remoting stuff, so I don't know an .asp from a hole in the ground.

Here's the link that shows how to do it:
http://www.macromedia.com/support/flash/ts/documents/flashvars.htm

Also: be aware that these values can be seen by the user, if they care to dig enough, don't put really sensitive info in these variables.

Put the path in the flashvars variable and add the filename to the string inside of the SWF.

var thePath = _root.RootPath + "/myfile.asp";

You could also dynamically generate the flashvars variable in the page that has the object / embed tags for the SWF something like (in ColdFusion)
PHP:
RootPath="<cfoutput>#CGI.HTTP_HOST#</cfoutput>/wwwroot"
 
peptoabysmal said:
In this way you can simply edit the path in the HTML file that calls the SWF when you change servers.
Trouble is, the design spec calls for being able to rapid deploy the swf's without re-compiling. Hard coding the webroot wasn't an option.

I did finally manage to come up with a solution. For reasons that had nothing to do with the Flash files, I found out that all the flash files were to always be stored within a parent directory (or rather, the great-grandparent directory, I guess) of a specific name. Using that, I was able to strip the web root out of the referencing url. And presto!

It was a lucky break that the one parent directory name was constent. My next step, like you said, was going to be building an external page that determined that information for me, except I was going to use an .asp page instead of ColdFusion.
 
Okay, you're all so smart ;) riddle me this, then:

I want to do pull in the results of an .asp page as a text string. Any ideas on how to pull that off?
 
Upchurch said:
Okay, you're all so smart ;) riddle me this, then:

I want to do pull in the results of an .asp page as a text string. Any ideas on how to pull that off?

Is Flash remoting an option? I use the CF side to generate a query to my database, then Flash can slurp the entire query into a RecordSet class for use within the swf. It is fast too. Remoting is supposed to work with .NET (is the same as .asp???) Seems like a lot of trouble for a single string, though.

If it's something that is more or less static, that is; to just be called on when the swf is first loaded, we usually use flashvars and create the name-value pairs dynamically in the CF page that contains the Flash embed code, but most of the data we use is dynamic and has to be pulled from a database depending on what actions the user takes. Could you embed the swf in the .asp page and load the string that way?

Other than that, I don't know; maybe dynamically create an XML doc and use the XMLload_whatever functions? Sorry, I know so little about .asp :(
 

Back
Top Bottom