tags:

views:

191

answers:

4

In the past I have created a php file that generates the XML and then referenced it in place of the xml file and it has worked. I am trying this with a precompiled flash app and it is not working.

Any ideas why?

It works if I run the script, save it and then reference that file to the swf. I would rather not generate a file to the filesystem if possible. Anyone any solutions?

+1  A: 

Without further information (code etc) I can only guess:

  • Are you trying to execute it on a server? php needs to be interpreted to generate the actual XML output, so if you don't put it on a webserver (that supports php), no content will be generated and the flash movie just sees the php code.
  • Check the content of the loaded php/XML file, trace it into some text field for debugging, so you can check if the actual content is being loaded correctly.
  • Listen for all available events of the URLLoader object. Maybe there is some IO error, you are not seeing. Alternatively you can also use the Flash debug player to see if errors are being thrown.

Also: What ActionScript version are you using?

poke
PHP is doing its job just fine as if I run the script and save it then reference it to the swf it works just fine
Mark
I know very little about flash... could the time the PHP takes to generate the XML, as opposed to it being available instantly be the reason?
Mark
I'm not talking about the php file alone. I am sure that works good enough. I'm talking about the whole chain where Flash tries to open that php file. And you cannot check that by separating the chain.
poke
unfortunately this is a precompiled app and the source code is unavailable. :S
Mark
No, the php file generates the content and returns the content then. Flash starts to load the file (and executes it) and will wait until the script has fully loaded – similar to how your browser will wait until the page has completely loaded. **Unless** your script tries to access the file directly, without listening to events, but you would know that by tracing the output. You should post some of your source code if you want further help.
poke
Oh, that's bad. Could you post some information how you configure the app then (i.e. how you set the path to the xml file it should open), or even better give a link to the application, so I could check?
poke
sure... DIY map - http://backspace.com/mapapp/configure.html#embed ... thanks for your help :)
Mark
Any luck, poke?
Mark
Sorry, no idea :/ The only thing I could imagine now is that the http request fails, because the location is not correct or something like that. Try out prodigitalson's 2nd tip to check that.
poke
A: 

Without seeing any of the code I would suspect the content type header isn't being set correctly and the php script is sending as html.

You can set the content type with the header funciton:

header('Content-Type: text/xml');

Joshua Smith
Flash doesn't care about the MIME type of the file it is loading. It gets the content as text, and the XML class then tries to interpret it as XML.
poke
already tried it, no luck... thanks anyway
Mark
+1  A: 

IF you pull the php page up in the browser are you sure that:

  1. The file has no white space preceding the XML prolog (<?xml version="1.0" ... ?>)
  2. The XML is wellformed

Another thing to check would be to look in firebug on the net panel... it shoudl show all the requests/responses made - including those done by flash (im assuming this is embedded in a web page). Look and make sure your flash is actually looking for the file you think its supposed to be looking for.

prodigitalson
Checked the XML, its wellformed and has no white space preceding the XML prolog, also the XML works if I save what the PHP file generated
Mark
firebug saved the day :) Thanks
Mark
Firebug has a knack for doing that ;-)
prodigitalson
Me and a friend are having a similar issue :( What did Firebug tell you? http://stackoverflow.com/questions/2413266/reading-php-generated-xml-in-flash
Leon
A: 

I'd suggest checking if some setting in your php.ini causes the output to be compressed (zlib.output_compression or ob_gzhandler).

djn