View Full Version : reading remote XML locally
Bowie
04-12-2006, 10:19 PM
I need to be able to read an xml file off of a remote server locally. Is this possible? everytime I use myXMLOBject.load(rendersXML.php); I get an error. please tell me there is someway around this..... please
Bowie
04-12-2006, 10:40 PM
Alright so I guess I'm out of luck..
When using this method, consider the Flash Player security model:
For Flash Player 8:
Data loading is not allowed if the calling SWF file is in the local-with-file-system sandbox and the target resource is from a network sandbox.
Data loading is also not allowed if the calling SWF file is from a network sandbox and the target resource is local.
For more information, see the following:
Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash
The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security
The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/fp8_security_apis
my project requires this because it is a kiosk that is reading the data. loadVars doean't work either. does anyone know a workaround? I'm essentially trying to download images into a movie, I see that I can't use the MovieClipLoader Either....
Flash Gordon
04-12-2006, 10:51 PM
why not chage the content type in the headers() of the PHP file to xml?
EDIT: Oopss. miss read. Read about cross domain issue. I like to "SHIM".
Bowie
04-12-2006, 10:59 PM
SHIMMING?! eh
excellent, thank you very much... now let's see if we can get this to work
http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_16520
Bowie
04-13-2006, 05:52 PM
here's a small update to my progress. I've discovered that Flash 8 allows for setting a security parmater that overrides the Flash Player security model. I'm faced with the possibility of the kiosk that I'm working on being deployed at multiple sites not knowing their IP addresses. So this is perfect.
System.security.allowDomain("*"); overrides the Flash Player security model! for crossing domains! great for this. and I'm not worried about information sensitivity.
I've run into another problem however. I'm not a php programmer, and have just started to touch the stuff. I've been using this script to output to an XML file that flash can read. <?php $files = array();
$handle = opendir("dir/dir");
while (false !== ($file = readdir($handle))) {
if($file != "." && $file != "..") {
$files[] = $file;
}
}
closedir($handle);
echo "<?xml version=\"1.0\"?>\n";
echo "<images>\n";
for($i=0; $i< count($files); $i++){
echo "<img>" . $files[$i] . "</img>";
echo "\n";
}
echo "\n";
echo "</images>\n";
/*echo "&files=" . implode("|", $files);*/
?>
the problem is that it spits them out, out of order. I'm sure that php has some handy means by which to add them in alphabetical order. I'm trying to figure it out.
Bowie
04-13-2006, 06:48 PM
nother update. found the line of code to sort the array in php: array_multisort($files, SORT_ASC);
but for some reason I cannot seem to get my local movies to load the remote shim with the System.security.allowDomain("*"); defined. I even setup the default crossdomain.xml file to allow wildcards... :(
Bowie
04-13-2006, 07:36 PM
If anyone has found this thread interesting to this point they might be into knowing that I've been able to get the Shim to work from one server to another, the same way that I had it set-up. but I still cannot get the shim to load into my movie on my machine locally.... guess the wildcard paramater doesn't allow access from everywhere afterall, maybe there's something screwy with our network config? I don't know where else to look...
Flash Gordon
04-13-2006, 07:40 PM
maybe the shim wont work from local to remote. It does remote to remote fine.
Why do you need to get a remote script locally? Sometimes if you just answer the why, people will give you better options.
darkangel333
04-24-2006, 09:14 PM
If I understand you correctly, you are trying to access an XML file on another server with a different domain name (i.e. accessing XML.xml on "fubar.com" while the SWF if on "fubar2.com"). If this is the case, here is the solution:
It's called a crossdomain.xml file. Go into NotePad and create a file with this name. Then, copy and paste the following:
******
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="www.fubar.com" />
</cross-domain-policy>
******
You can change the domain to what you wish and you can add additional lines of "allow-access-from". Wildcards ("*.fubar.com") also qork quite well.
Save this file and place it in the ROOT of the server directory. Flash will look for this file in the root directory, so ensure it is placed there.
For supporting documentation on this process, see Macromedia's LiveDoc here:
http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001618.html
Cheers.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.