title: How to load PHP dynamically generated XML in FLASH
body: <p><em>Question Updated for Bounty</em></p>
  
  <p>In Flash I need to load a dynamically generated XML file, which is created using PHP.</p>
  
  <p>I'm using the [Bulk-loader library][1] for all my loading.</p>
  
  <p>Currently my Flash can only load a manually created XML file, what I need Flash to do is to load a PHP generated XML File like this: <br/>
  --- XML path removed ---</p>
  
  <p>When I test movie in Flash using that PHP generated XML File it will work, however the problem lies when I try to either test locally in an HTML page or online. The Flash does not render completely because of some problem obtaining data from the XML.</p>
  
  <p><br/></p>
  
  <p><strong>Here are some links to show where I'm at right now:</strong></p>
  
  <p>[FLash using manually generated XML file][2]<br/>
  ^ Uses: [The XML file][3]<br/></p>
  
  <p>[Flash using PHP generated XML file][4]<br/>
  ^ Uses: [The PHP generated XML File][5]</p>
  
  <p><br/></p>
  
  <p>I searched the Bulk-loader Wiki on how to load a PHP file and for loading type information and found this: [<a href="http://code.google.com/p/bulk-loader/][6]" rel="nofollow noreferrer">http://code.google.com/p/bulk-loader/][6]</a> </p>
  
  <pre><code>bulkInstance.add("http://mysite.com/top-ten.php", {type:"text"});
  bulkInstance.add("http://mysite.com/top-ten.php", {type:"xml"});
  bulkInstance.add("http://mysite.com/top-ten.php", {type:"image"});
  </code></pre>
  
  <p><br/></p>
  
  <h2>CODE Snippets</h2>
  
  <p><strong>Here is my current code that loads an XML file:</strong><br/>
  '<strong>theXML</strong>' variable is obtained form the FlashVars from the HTML</p>
  
  <pre><code>private function init(e:Event = null):void 
      {
          removeEventListener(Event.ADDED_TO_STAGE, init);
  
          stage.scaleMode = StageScaleMode.NO_SCALE;
          stage.align     = StageAlign.TOP_LEFT;
          theXML          = this.loaderInfo.parameters.theXML;
          loader          = new BulkLoader("bulky");
          loader.logLevel = BulkLoader.LOG_INFO;
          loader.addEventListener(BulkLoader.COMPLETE, onBulkLoadComplete);
          loader.addEventListener(BulkLoader.PROGRESS, onBulkLoadProgress);
  
          /* ------------------------------------------- TESTING */
          //Below is manual XML, works when tested local &amp; online
          //loader.add("client_user.xml",{id:"xmldata"});
  
          //Below uses PHP generated XML, works when tested in Flash, but no where else
          //loader.add("--- XML path removed ---",{id:"xmldata", type:"xml", maxTries: 6, preventCache:true});
  
          /* ------------------------------------------- LIVE */
          //loader.add(theXML,{id:"xmldata"});
          loader.add(theXML,{id:"xmldata", type:"XML", maxTries: 6, preventCache:true});
  
          loader.start();
      }
  </code></pre>
  
  <p><br/><br/></p>
  
  <p><strong>onBulkLoadComplete code</strong></p>
  
  <pre><code>private function onBulkLoadComplete(e:Event):void
  {
  trace("[BulkLoader] COMPLETE"+"\r");
  
  Global.xml   = loader.getXML("xmldata");
  HEX          = Global.xml.config.hex.toString(),{id:"hex"};
  globalWidth  = Global.xml.config.width.toString();
  globalHeight = Global.xml.config.height.toString();
  videoHeight  = (globalHeight - (thumbMenuH + videoY + spacedBtn));
  controlsY    = (videoHeight + videoY);
  
  trace("············· Config ·············");
  //trace(" HEX          = "+HEX);
  //trace(" globalWidth  = "+globalWidth);
  //trace(" globalHeight = "+globalHeight);
  //trace("··································");
  //trace("\r");
  
  // ------------------------------------------------------ XML ARRAY
  var x, i;
  
  for(x in Global.xml.tab) {
      for(i in Global.xml.tab[x].vid) {
          videos.push(Global.xml.tab[x].vid[i].@flv);
          thumbTitles.push(Global.xml.tab[x].vid[i].@title);
          thumbPaths.push(Global.xml.tab[x].vid[i].@thumb);
      }
  }
  
  // ------------------------------------------------------ XML ARRAYS            
  videoName  = videos[0]; // Current video is the 1st video
  
  drawBackground();
  drawVideo();
  drawControls();
  drawTabMenu();
  
  // -------------------------------- FIND DEFAULT IMAGE/VIDEO TO LOAD
  for(x in Global.xml.tab) {
      for(i in Global.xml.tab[x].vid)     {
          if (Global.xml.tab[x].vid[i].@default == "true") {
              //override any flv qued in the display
              firstTitle = Global.xml.tab[x].vid[i].@title;
              vd.flvPath = Global.xml.tab[x].vid[i].@flv;
  
              //load the default thumbnail
              loader = new BulkLoader("thumb");
              loader.addEventListener(BulkLoader.COMPLETE, onThumbComplete);
              loader.add(new URLRequest(Global.xml.tab[x].vid[i].@thumb),{id:"defaultThumbnail"});
              loader.start();
              break;
          }
      }
  }
  }
  </code></pre>
  
  <p><strong>HTML Embed Code:</strong></p>
  
  <pre><code>&lt;div&gt;
      &lt;h2&gt;Testing TEN player on external domain&lt;/h2&gt;
      &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="301" height="353"&gt;
      &lt;param name="movie" value="http://www.domain1.com/N/N.swf"&gt;
      &lt;param name="quality" value="high"&gt;
      &lt;param name="flashVars" value="theXML=http://dev.domain2.com/admin2/client.php?id=2" /&gt;
      &lt;embed src="http://www.domainname.com/N/N.swf" flashVars="theXML=http://dev.domain2.com/admin2/client_user.php?id=2" allowscriptaccess="always" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="301" height="353"&gt;
      &lt;/embed&gt;
      &lt;/object&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><br/><br/></p>
  
  <h2>Question:</h2>
  
  <p>1) How to load a dynamically generated XML file that ends in .php in Flash and render the Flash correctly in an HTML<br/></p>
  
  <p><br/></p>
  
  <h2>UPDATE</h2>
  
  <p>We got the Flash to read the PHP generated XML file, however we can only view working results when we 'Test Movie' from inside Flash. When we try to get it to work in an HTML page locally or online it won't render correctly.</p>