PDA

View Full Version : dynamic URL path


LukeManic
03-19-2007, 01:10 PM
Hi guys, I'm slightly new to flash and have come across something which is making my head ache :p

Ive got a movie which fetchs information from a database and prints it within the flash movie, this all works fine until I change the server which the .swf file is on. It means I have to go back into the flash file and manually change the URL path to the relevant domain.

So in small I would like to know how to dynamically change the URL path below based on the server it is located on, is this possible in flash?

onClipEvent(load){
loadVariables("http://www.domainname.com/read.php", this, "GET");
}

Thanks in advance,

Luke.

jagadeish
03-21-2007, 07:07 AM
Hi,

There is no need to write the domain name here,
ok..
create a folder on server and give the name like "read"
and paste the read.php in it.. for example if ur swf name is contact.swf then paste it on sever root. like this

webserver->root -> contact.swf
-> read (folder) -> read.php



onClipEvent(load){
loadVariables("read/read.php", this, "GET");
}

this will work on any server..

Regards
Jagadeish..

wvxvw
03-21-2007, 02:48 PM
// hostname
var __hostname:String = "";
var tmp_str:String = _url;
tmp_str = tmp_str.slice(tmp_str.indexOf("//")+2, tmp_str.indexOf("/", 20));
while (tmp_str.charAt(0) == "/") {
tmp_str = tmp_str.substr(1-tmp_str.length);
}
while (tmp_str.indexOf("/")>=0) {
tmp_str = tmp_str.slice(0, tmp_str.lastIndexOf("/"));
}
__hostname = "http://"+tmp_str;

LukeManic
03-21-2007, 05:29 PM
Thats great guys, thanks very much for your help :)