2011-09-16 70 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