【问题标题】:FLASH as3 not able to identify localhost php web addressFLASH as3 无法识别 localhost php 网址
【发布时间】:2011-10-16 23:24:38
【问题描述】:

我正在尝试使用 php(products.php) 检索 mysql 数据并将 xml 格式的数据返回到 ADobe flash as3;但我收到以下错误。

Error opening URL 'http://localhost/Flash/player/products.php'

错误 #2044:未处理的 ioError:。文本=错误 #2032:流错误。网址:http://localhost/Flash/player/products.php php_mysql3_as3_fla::MainTimeline/frame1()

请任何建议或帮助为什么 flash 无法识别 http://localhost/Flash/player/products.php 地址。我安装了 WAMP;这工作正常,因为我有许多其他 php 项目在这里工作。

提前感谢您的帮助和建议。

以下是我的php代码

<?php
    $link = mysql_connect("localhost","root","");

mysql_select_db("test");

$query = "select * from products";
$results = mysql_query($query);


echo '<?xml version="1.0" encoding="utf-8" ?>'." \n";
echo"<GALLERY>\n";
$cnt=0;
while($line=mysql_fetch_assoc($results))
{
    echo '<IMAGE TITLE="'.$cnt.'">'.$line['product'].'</IMAGE>'." \n";
    $cnt++;
}

echo "</GALLERY>\n";

mysql_close($link);

?>

php 文件位于 c:\wamp\www\Flash\player\products.php


下面是我的 AS3 flash 代码

var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

//myLoader.load(new URLRequest("c:\\wamp\\www\\Flash\\player\\products2.xml"));
myLoader.load(new URLRequest("http://localhost/Flash/player/products.php"));
myLoader.addEventListener(Event.COMPLETE, processXML);


function processXML(evt:Event):void {

myXML = new XML(evt.target.data);
for (var i:int = 0; i<myXML.*.length(); i++){
trace("My image number is " + (i+1) + ", it's title is " + myXML.IMAGE[i].@TITLE + " and it's URL is " + myXML.IMAGE[i]);
};
//trace("data: " + myLoader.data);;
}

【问题讨论】:

  • 如果您在浏览器中使用相同的 URL 是否有效?请记住,Apache 区分大小写。

标签: php mysql flash


【解决方案1】:

在聊天中发现问题出在防火墙上。

这是另一个相关的问题:

Testing movie with Flash IDE fails to load file from localhost

【讨论】:

  • 是一个漫长的旅程,感谢 davgothic 写下了他的解决方案。
【解决方案2】:

这是可能的:

  1. 您的电影在本地领域运行,并且您正在尝试加载网络资源(我想会是这种情况)。在这种情况下,您需要添加编译标志:-use-network=true

  2. php文件不存在。

您总是需要捕捉 URLLoader 事件:

dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

看看发生了什么!

查看这些事件处理程序的实际效果:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html#includeExamplesSummary

【讨论】:

  • 感谢您的回复。我的 .fla 文件位于 c:\wamp\www\Flash\player\test.fla 位置,而 php 文件位于 c:\wamp\www\Flash\player\products.php 位置。我在同一个系统上运行 WAMP 服务器。对不起,我没有得到你的第一点。
  • trace(Security.sandboxType) 输出什么?
  • 请将所描述的侦听器附加到您的myLoader 并捕获错误事件:trace (event); Flash 当前抱怨未处理的 IO 错误,因此可能并且很可能您的 php 文件无法访问你的本地主机。
  • 我尝试在浏览器中本地加载 php 文件。它呼应正确的输出。 php mysql 没有问题,多年来一直在研究它。但我是 Flash 新手 :( 添加了 var dispatcher:CustomDispatcher = new CustomDispatcher(); dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler); dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); 现在它给调度员的错误
  • @ParagRedkar 让我们continue this discussion in chat
猜你喜欢
  • 2019-09-14
  • 1970-01-01
  • 2013-12-31
  • 2016-07-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-25
  • 2015-04-23
相关资源
最近更新 更多