Flash_flea
Flash_flea

Reputation: 1

How does one translate this code to ActionScript 3.0?

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? 

Upvotes: 0

Views: 96

Answers (2)

papachan
papachan

Reputation: 1909

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);
   }

Upvotes: 2

john
john

Reputation: 434

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");
}

Upvotes: 0

Related Questions