我对这段代码感到难过 - 似乎每次我移植这个AS2代码的一些保留字(它的作用是使用Flash和PHP发送邮件),我收到错误
stop();
var senderLoad:LoadVars = new LoadVars();
var receiveLoad:LoadVars = new LoadVars();
sender.onRelease = function() {
senderLoad.theName = theName.text;
senderLoad.theEmail = theEmail.text;
senderLoad.theMessage = theMessage.text;
senderLoad.sendAndLoad("http://leebrimelow.com/mailExample/send.php",receiveLoad);
}
receiveLoad.onLoad = function() {
if(this.sentOk) {
_root.gotoAndStop("success");
}
else {
_root.gotoAndStop("failed");
}
}
Any idea how?
答案 0 :(得分:2)
如果您将LoadVars对象更新为As3,只需使用类似此代码的UrlLoader对象。
var mainLoader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("http://domain/mailExample/send.php");
var variables:URLVariables = new URLVariables();
variables.theName = theName.text;
variables.theEmail = theEmail.text;
variables.theMessage = theMessage.text;
request.method = URLRequestMethod.POST;
request.data = variables;
mainloader.addEventListener(Event.COMPLETE, handleComplete);
mainLoader.load(request);
private function handleComplete(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
}
答案 1 :(得分:0)
我不是AS2的专家,但我可以帮助您使用此代码所需的AS3语法 试着看看会对你有所帮助 它是AS3概念的基础
那是AS3函数语法
bldg1_thumb1.addEventListener(MouseEvent.CLICK, MyFunction);
function MyFunction (event:MouseEvent):void{
gotoAndStop ("2");
}