如何加载PHP的FLASH动态生成的XML [英] How to load PHP dynamically generated XML in FLASH

查看:109
本文介绍了如何加载PHP的FLASH动态生成的XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题更新了赏金

在闪存我需要加载一个动态生成的XML文件,使用PHP这是创建的。

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

我使用的是[批量加载程序库] [1]为我所有的加载。

I'm using the [Bulk-loader library][1] for all my loading.

目前我的Flash只能加载手动创建XML文件,我需要Flash做的是加载一个PHP产生这样的XML文件:
--- XML​​路径中删除---

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:
--- XML path removed ---

当我使用PHP生成的XML文件,将工作,但问题在于,当我尝试这两项测试中在本地的HTML页面或在线Flash中测试影片。闪存没有完全呈现,因为一些问题,从XML中获取数据。

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.


这里有一些链接,以显示我在哪里现在:

[使用手动生成的XML文件flash] [2]
^用途:将XML文件] [3]

[FLash using manually generated XML file][2]
^ Uses: [The XML file][3]

[闪光灯使用PHP生成的XML文件] [4]
^用途:在PHP生成的XML文件] [5]

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


我找遍了大容量装载的Wiki如何加载一个PHP文件并加载类型的信息,发现这:HTTP://$c$c.google.com/p/bulk-loader/] [6]

I searched the Bulk-loader Wiki on how to load a PHP file and for loading 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加载XML文件:
theXML 变量的形式从HTML中获得的FlashVars

Here is my current code that loads an XML file:
'theXML' variable is obtained form the FlashVars from the 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:

<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)如何加载结束以.php在Flash动态生成的XML文件,并正确地呈现闪光在HTML

1) How to load a dynamically generated XML file that ends in .php in Flash and render the Flash correctly in an HTML


我们得到了闪存读取PHP生成的XML文件,但是我们只能查看工作结果时,我们测试影片从内闪存。当我们设法得到它在HTML页面在本地工作或在网上就无法正常渲染。

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.

推荐答案

从您的输出:

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

看来,问题不在于装载机但与PHP的输出。检查以确保您的输出看起来有望直接从浏览器访问生成的XML和下载。您可以如果您在文本编辑器通过它去行由行发现错误输出,或者你可以尝试使用XML编辑器,看看它是否发现的问题。

It seems that the problem is not with the loader but with the PHP output. Check to make sure your output looks as expected by accessing the generated XML directly from your browser and downloading it. You may be able to spot the error in the output if you go through it in a text editor line-by-line, or you could try using an XML editor and see if it finds issues.

这篇关于如何加载PHP的FLASH动态生成的XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆