从PHP数据传递到Flash [英] Passing Data from PHP to Flash

查看:180
本文介绍了从PHP数据传递到Flash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得通过从PHP到Flash的一些基本数据。从阅读的话题我知道最好的方法是创建XML与PHP然后阅读在Flash。我想开始了简单,所以这里是我的PHP code:

I am trying to get some basic data passed from PHP to Flash. From reading on the topic I understand the best way is to create XML with PHP then read it in Flash. I am trying to start out simple so here is my PHP code:

<?php
    header('Content-Type: text/xml');
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    echo "<userData>";
    echo "<firstName>John</firstName>";
    echo "<lastName>Smith</lastName>";
    echo "</userData>";
?>

这里是我的Flash code:

And here is my Flash code:

var xml:XML = new XML();
var url:URLRequest = new URLRequest("data.php");
var loader:URLLoader = new URLLoader(url);
loader.addEventListener("complete", xmlLoaded);

function xmlLoaded(event:Event):void
{
    xml = XML(loader.data);
    trace("Data loaded.");
    trace (loader.data);
};

我已经看到了使用这种方法,一些教程和它的作品却在Flash我收到此错误:

I've seen some tutorials that use this approach and it works however in Flash I receive this error:

类型错误:错误#1088:下面的根目录下的文件中的标记   必须很好地形成的元件

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

任何人能确定为什么我得到这个错误,或者提供了这样做的另一种方式?

Can anyone determine why I get this error or provide another way of doing this?

推荐答案

这是非常清楚的,你的XML格式,不接受FLASH。所以你需要非常精确的,你写的方式一闪念一个非常格式的XML。

It is very clear that your XML format is not accepted by FLASH. FLASH read a very formatted XML so you need to be very accurate in the way you write it.

我建议使用XML类的形式PHP构建你的XML DOM文档一样。我使用这个类在我的项目的FLASH和其作品的罚款。

I suggest using a XML class form php to build your XML like DOMDocument. I am using that class in my project for FLASH and its works fine.

祝你好运。

这篇关于从PHP数据传递到Flash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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