PDA

View Full Version : relative path of files on server?????


3pepe3
08-03-2007, 03:28 AM
Hello world.
This question I don’t know if must be in actionscript2 or server side-scripting. But I feel that this is the correct section.
The problem is: I have a main.swf that loads askphp.swf and this askphp sendandload answer.php.
Folder structure:

page/ (folder)


main.html


main.swf


swfs/ (folder)


otherfolder/


askphp.swf


phps/ (folder)


answer.php


but I can’t find the way to get answer… in a textfield I’m getting "Error connecting to server."
askphp.fla

//simplified version
var answer_lv:LoadVars = new LoadVars();
answer_lv.onLoad = function(success:Boolean) {
if (success) {
t.text = answer_lv.info ;
} else {
t.text = "Error connecting to server.";
}
};
var send_lv:LoadVars = new LoadVars();
send_lv.sendAndLoad("phps/answer.php",answer_lv,"POST");

The answer.php:

<?php
//simplified version
echo "&info=hello world&";
?>

What I think is that the problem is referencing to the php file.

send_lv.sendAndLoad("phps/answer.php",answer_lv,"POST");
//but I think that main.swf is the root so the php file is phps/answer.php
//also another option was that php must be relative to the askphp.swf so I changed the path to:
//send_lv.sendAndLoad("../../phps/answer.php",answer_lv,"POST");// but this method was just working outside the main.swf

Any advice???

3pepe3
08-03-2007, 04:17 AM
Well now I’m confused… I don’t know what was happening but now al is working
And what I have learned is that the SWFs loaded into another SWF will need to use the proper path for all the external information that they will need to load. The proper path will be relative to the original (main.swf) SWF and not the relative path of the loaded SWF.
in this case 'phps/answer.php' was correct
Hope this is helpful.

CyanBlue
08-03-2007, 08:46 AM
I think it is more correct to say that the path is relative to the main.html which embeds your main.swf file... ;)

3pepe3
08-03-2007, 09:43 AM
you are right... Thanks for the correction (also it's more clear).
:)

CyanBlue
08-03-2007, 10:10 AM
My pleasure... ;)

3pepe3
08-07-2007, 01:45 PM
path from php:
http://www.actionscript.org/forums/showthread.php3?p=639756&posted=1#post639756