5 Replies Latest reply on Nov 6, 2007 6:41 AM by The Feldkircher

    PHP generated XML files in Flash

      I want to create a flash based frontend for my image gallery system. I need to load in an php generated xml file (something like images.php). But Flash seems to load the unparsed xml file (webserver with php works fine). Maybe that's just happening in the authoring environment. I'm trying to load the xml file with the XML-connector. Can someone give me an advice before I do hours of trial'n'error business?
        • 1. Re: PHP generated XML files in Flash
          clbeech Level 3
          use the LoadVars to recieve the php doc, and in the onLoad handler, construct a XML doc from the return, then parse and construct an array from the element attributes (I assume they are file paths to images) then you can use the array to load the images from the paths as stored. But do so with AS code, you don't need to use the XMLconnector, it's more for service-based applications.
          • 2. Re: PHP generated XML files in Flash
            maroudi Level 1
            It seems like I don't get my foot into the AS/XML door. My XML looks like this:


            (Close tags not shown)

            The XML file is valid and works with XML-connector. I try to access the XML data with this AS:

            xml_doc = new XML();


            xml_doc.onLoad = function(success) {
            xml_doc.ignoreWhite = true;


            var mainnode:XMLNode = xml_doc.firstChild;

            var imagenodes:Array = xml_doc.firstChild.childNodes;
            for (var i:Number = 0; i < imagenodes.length; i++) {
            // for each person node:
            var imagenode:XMLNode = imagenodes ;


            I'm not getting any values out (just 'undefined'). There seems to be something missing, but I just don't find out what.


            • 3. Re: PHP generated XML files in Flash
              clbeech Level 3
              couple of things here. I think I would consider making attributes of url, name and etc, in each 'image' node, it will be easier to get the value in Flash that way without having to remove the node 'tags' from the XML elements.

              here is a small example (not using php generated xml) that uses attributes verses nodes: FOLDER

              But that aside from that, I think I'd structure the XML loading code a little differently, more like below:
              • 4. Re: PHP generated XML files in Flash
                maroudi Level 1
                Thanks a lot! With accessing the attributes it's working well. Is accessing the node values so much harder?
                • 5. Re: PHP generated XML files in Flash
                  The Feldkircher

                  Take a look at this it does exactly what you want - without having to write an XML Parser.

                  It uses a XML Connector and a Dataset to receive PHP generated xml - you can download the complete file to see how it works at the same location.

                  Hope it helps