问题
I'm stumped with this code - it seems that every time I port some of the reserved words of this AS2 code (what it does is to send mail using both Flash and PHP), I'm getting errors
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?
回答1:
If you update LoadVars Object to As3 just use an UrlLoader Object like this code.
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);
}
回答2:
I'm n't expert in AS2 but I can help you with the syntax of AS3 you need for this code try to see would help u it's the basic of the AS3 Concepts
mouseevent as3
Function As3
and that's AS3 function syntax
bldg1_thumb1.addEventListener(MouseEvent.CLICK, MyFunction);
function MyFunction (event:MouseEvent):void{
gotoAndStop ("2");
}
来源:https://stackoverflow.com/questions/7450788/how-does-one-translate-this-code-to-actionscript-3-0