我创建了一个简单的Flex应用程序来获取XML文件。我需要一个Flex变量“id”从XML代码中的标签中获取“letters”值,然后在Alert窗口中显示该id。当我现在运行此代码(使用完整代码)时,警报框为空。Flex/PHP/XML数据问题
当我运行Flex中调试模式下的应用程序,这是Flex的看到:http://static.readescdn.com/misc/flex.gif
下面是Flex和XML代码(编辑,只显示有什么不工作):
// Flex
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication ...
creationComplete="windowedapplication1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
// Send the HTTP request
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
xmlService.send();
}
// Receive the HTTP response
protected function xmlService_resultHandler(event:ResultEvent):void
{
// Grab the id
var id:String = xmlService.lastResult.data.id;
// Show an alert with the id
Alert.show(id);
}
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService id="xmlService"
url="http://localhost/file.xml"
method="GET"
useProxy="false"
resultFormat="e4x"
result="xmlService_resultHandler(event)"/>
</fx:Declarations>
</s:WindowedApplication>
// XML
<?xml version="1.0"?>
<data>
<id>letters</id>
<letter label="Letter A">a</letter>
<letter label="Letter B">b</letter>
<letter label="Letter C">c</letter>
</data>
你需要缩小你的代码,并告诉我们问题区域问题 - 一个小的代码粘贴到你的问题,你不能指望别人去通过所有代码。在你的问题中,你说你可以看到PHP发送到Flex客户端的XML数据,然后继续说“但是Flex没有收到任何东西” - 也许你没有引用PHP发回的内容是否正确? – Abs 2010-04-08 15:42:01
对不起。那还好吗? – Reado 2010-04-08 16:27:21