Flash-to-PHP:Vars-don';不能传入SWF文件
我正在做一个Actionscript 3脚本(使用Flash 13),它接收用户的电子邮件,然后将其发送到我网站上的PHP文件,PHP文件将格式化一封电子邮件,并将其发送到用户的地址。没有什么太复杂的,当我在Flash中测试它时,它工作得很好。但一旦我导出电影,它似乎就无法再“联系”PHP文件了。PHP文件有一个错误处理条件,因为我根本没有收到电子邮件,我知道问题出在Flash上 我尝试将嵌入网页的Flash文件托管在与PHP文件相同的服务器上,但没有结果 以下是我的AS代码:Flash-to-PHP:Vars-don';不能传入SWF文件,php,actionscript-3,flash,Php,Actionscript 3,Flash,我正在做一个Actionscript 3脚本(使用Flash 13),它接收用户的电子邮件,然后将其发送到我网站上的PHP文件,PHP文件将格式化一封电子邮件,并将其发送到用户的地址。没有什么太复杂的,当我在Flash中测试它时,它工作得很好。但一旦我导出电影,它似乎就无法再“联系”PHP文件了。PHP文件有一个错误处理条件,因为我根本没有收到电子邮件,我知道问题出在Flash上 我尝试将嵌入网页的Flash文件托管在与PHP文件相同的服务器上,但没有结果 以下是我的AS代码: myEmail
myEmail = result.text;
var myData:URLRequest = new URLRequest("http://www.mywebsite.com/sendmail.php");
myData.method = URLRequestMethod.GET;
var variables:URLVariables = new URLVariables();
variables.email = myEmail;
myData.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, dataOnLoad); // the dataOnLoad functions only does a trace
loader.load(myData);
还有我的PHP:
if (!empty($_GET)) {
$to = $_GET['email'];
$message = "Hurray !!!";
mail($to, 'Here is your coupon !', $coupon);
} else {
mail('me@mysite.com', 'Error', 'Your GET info is faulty my friend');
}
我应该知道这些功能是否有一些限制?还是导出电影时要检查的选项
谢谢大家的帮助 下面是一个脚本,它将把变量加载到数组中。我使用它将变量从php传递到AS3 flash swf文件,使用“$returnString=http\u build\u query($returnVars);” 闪光
var myarray;
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("http://www.mywebsite/thescript.php");
request.method = URLRequestMethod.GET;
trace("loadingScript");
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(request);
//you set up your listeners and add:
function completeHandler(evt:Event)
{
var intiCount = 0;
for each (var obj:Object in evt.target.data)
{
myarray.push(obj);// each item will be pushed into array
intiCount++;
trace(myarray[i]) ; // i= will loop each item i= 0,1,2
// output: whatever1, what ever2 ,what ever 3.
}
}
PHP脚本:
<?php
$returnVars['item1'] = "whatever1";
$returnVars['item2'] = "whatever2";
$returnVars['item3'] = "whatever3";
$returnString = http_build_query($returnVars);
echo $returnString;
//the items are now in key pairs in flash.
?>
下面是一个脚本,可以将变量加载到数组中。我使用它将变量从php传递到AS3 flash swf文件,使用“$returnString=http\u build\u query($returnVars);” 闪光
var myarray;
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("http://www.mywebsite/thescript.php");
request.method = URLRequestMethod.GET;
trace("loadingScript");
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(request);
//you set up your listeners and add:
function completeHandler(evt:Event)
{
var intiCount = 0;
for each (var obj:Object in evt.target.data)
{
myarray.push(obj);// each item will be pushed into array
intiCount++;
trace(myarray[i]) ; // i= will loop each item i= 0,1,2
// output: whatever1, what ever2 ,what ever 3.
}
}
PHP脚本:
<?php
$returnVars['item1'] = "whatever1";
$returnVars['item2'] = "whatever2";
$returnVars['item3'] = "whatever3";
$returnString = http_build_query($returnVars);
echo $returnString;
//the items are now in key pairs in flash.
?>
尝试用一个引号发送到php。。。我也遇到过同样的问题,在调用该文件时一定尝试了大约100个不同的版本。。。所以为了让它工作。。。试试>>“../yourphp.php”试着用一个引号发送到php。。。我也遇到过同样的问题,在调用该文件时一定尝试了大约100个不同的版本。。。所以为了让它工作。。。试试>>'../yourphp.php'也许你可以试试而不是做你可以做一些类似的事情,而不是通过代码来做。只是一个想法我不做actionscript:)试试var myData:URLRequest=newurlRequest(“http://www.mywebsite.com/sendmail.php?email=“+邮件)代码>感谢您的快速回答!不幸的是,它不起作用。似乎Flash电影的脚本甚至无法访问PHP文件。您是否遇到安全错误?你有flash调试器吗?您是否尝试过以“仅访问网络”的形式发布?您在处理安全性或其他方面绝对没有错误。你怎么可能指望它会告诉你有什么不对劲呢。下面是您应该实现的侦听器的分类。也许你可以尝试而不是做你可以做一些类似的事情,而不是通过代码来做。只是一个想法我不做actionscript:)试试var myData:URLRequest=newurlRequest(“http://www.mywebsite.com/sendmail.php?email=“+邮件)代码>感谢您的快速回答!不幸的是,它不起作用。似乎Flash电影的脚本甚至无法访问PHP文件。您是否遇到安全错误?你有flash调试器吗?您是否尝试过以“仅访问网络”的形式发布?您在处理安全性或其他方面绝对没有错误。你怎么可能指望它会告诉你有什么不对劲呢。下面是您应该实现的侦听器的分类。