问题已更新为Bounty
在Flash中我需要加载动态生成的XML文件,该文件是使用PHP创建的。
我正在使用[Bulk-loader library] [1]进行所有加载。
目前我的Flash只能加载手动创建的XML文件,我需要Flash做的是加载PHP生成的XML文件,如下所示:
---删除了XML路径---
当我使用PHP生成的XML文件在Flash中测试电影时,它会起作用,但问题在于我尝试在HTML页面本地测试或在线测试。由于从XML获取数据存在一些问题,Flash无法完全呈现。
以下是一些显示我现在所处位置的链接:
[使用手动生成的XML文件进行FLASH] [2]
^用途:[XML文件] [3]
[Flash使用PHP生成的XML文件] [4]
^用途:[PHP生成的XML文件] [5]
我搜索了Bulk-loader Wiki,了解如何加载PHP文件和加载类型信息,发现:[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"});
以下是我当前加载XML文件的代码:
“ theXML ”变量是从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嵌入代码:
<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>
1)如何在Flash中加载以.php结尾的动态生成的XML文件,并在HTML中正确呈现Flash
我们让Flash阅读PHP生成的XML文件,但是当我们从Flash内部“测试电影”时我们只能查看工作结果。当我们尝试让它在本地或在线的HTML页面中工作时,它将无法正确呈现。
答案 0 :(得分:2)
从你的输出:
Error #1088: The markup in the document following the root element must be well-formed.
似乎问题不在于加载程序,而在于PHP输出。通过直接从浏览器访问生成的XML并下载它,检查以确保输出看起来符合预期。如果您逐行在文本编辑器中查看错误,则可以在输出中发现错误,或者您可以尝试使用XML编辑器查看是否发现问题。
答案 1 :(得分:0)
尝试将此代码放在php文件的第一行:
header ("content-type: text/xml");
答案 2 :(得分:0)
您确定已将type:"XML"
放在联机测试TEN.swf的add
bulkloader
内,因为从PHP文件运行时出错了吗?
修改强>
从以前的TEN.swf读取字节码表明没有放入xml类型:
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
现在它似乎工作并显示字节码显示已添加xml类型
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