2011-09-16 49 views
0

我被这段代码弄得一团糟 - 似乎每次我移植这个AS2代码的一些保留字(它的作用是使用Flash和PHP发送邮件),我得到错误如何将此代码转换为ActionScript 3.0?

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

我不是在AS2专家,但我可以帮你AS3的你需要的代码 尝试,看看会帮助ü 它的AS3概念的基本语法

mouseevent as3

Function As3

,这就是AS3函数的语法

bldg1_thumb1.addEventListener(MouseEvent.CLICK, MyFunction); 

function MyFunction (event:MouseEvent):void{ 
    gotoAndStop ("2"); 
} 
+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); 
    } 
+0

所以,你告诉我,这只是我需要改变的代码的一部分 - 并保持原样? –

+0

是的其他代码已被弃用as3 – papachan