How to load dynamically generated PHP XML file in FLASH

Question updated for Bounty.

In Flash, I need to load a dynamically generated XML file that is created using PHP.

I use the [Bulk-loader library] [1] library for my entire download.

Currently, my Flash can only load a manually created XML file, I need Flash to load the created PHP XML file as follows:
--- Remote XML path ---

When I test a movie in Flash using this PHP file with PHP, it will work, however the problem is that I'm trying to either test locally on an HTML page or on the Internet. Flash does not display completely due to some problem with retrieving data from XML.


Here are some links to show where I am now:

[FLASH using a manually created XML file] [2]
^ Uses: [XML file] [3]

[Flash using PHP XML file] [4]
^ Uses: [XML file generated by PHP] [5]


I searched the Wiki Bulk-loader on how to download a PHP file and load type information and found this: [ http://code.google.com/p/bulk-loader/โ€ [6]

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 snippets

Here is my current code that loads an XML file:
' theXML ' is obtained from FlashVars from HTML

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 & 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();
    }



onBulkLoadComplete 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;
        }
    }
}
}

HTML code to insert:

<div>
    <h2>Testing TEN player on external domain</h2>
    <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">
    <param name="movie" value="http://www.domain1.com/N/N.swf">
    <param name="quality" value="high">
    <param name="flashVars" value="theXML=http://dev.domain2.com/admin2/client.php?id=2" />
    <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">
    </embed>
    </object>
</div>



Question:

1) How to load a dynamically created XML file that ends with .php in Flash, and correctly display Flash in HTML


UPDATE

Flash PHP XML, , Flash. HTML- , .

+3
3

:

Error #1088: The markup in the document following the root element must be well-formed.

, , PHP. , , , XML . , , XML , .

+2

php :

header ("content-type: text/xml");
0

, type:"XML" add of bulkloader - TEN.swf, PHP ?

Edit:

Reading the bytecode from the previous TEN.swf shows that the xml type was not placed:

0x000076  [ 0xd0 ]       GetLocal0                                                                
0x000077  [ 0x66 ]       GetProperty          QName(PrivateNamespace(""), "theXML")                                                    
0x00007a  [ 0x2c ]       PushString           "id"                                                    
0x00007d  [ 0x2c ]       PushString           "xmldata"                                                    
0x000080  [ 0x55 ]       NewObject            1                                                    
0x000082  [ 0x4f ]       CallPropVoid         QName(PackageNamespace(""), "add"), 2                                                    

Now it seems that the bytecode is working and showing that the xml type has been added

0x000076  [ 0xd0 ]       GetLocal0                                                                
0x000077  [ 0x66 ]       GetProperty          QName(PrivateNamespace(""), "theXML")                                                    
0x00007a  [ 0x2c ]       PushString           "id"                                                    
0x00007d  [ 0x2c ]       PushString           "xmldata"                                                    
0x000080  [ 0x2c ]       PushString           "type"        <===== here it is now                                            
0x000083  [ 0x2c ]       PushString           "xml"         <=====                                           
0x000086  [ 0x2c ]       PushString           "maxTries"                                                    
0x000089  [ 0x24 ]       PushByte             0x6                                                    
0x00008b  [ 0x2c ]       PushString           "preventCache"                                                    
0x00008e  [ 0x26 ]       PushTrue                                                                 
0x00008f  [ 0x55 ]       NewObject            4                                                    
0x000091  [ 0x4f ]       CallPropVoid         QName(PackageNamespace(""), "add"), 2                                                    
0
source

Source: https://habr.com/ru/post/1735676/


All Articles