dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: How do you convert this to ActionScript 3.0?

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    7

    How do you convert this 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
    Code:
    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?

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Give this a try:

    PHP Code:
    stop();
    sender.addEventListener(MouseEvent.CLICKsendMail);

    function 
    sendMail(e:MouseEvent null):void{
        var 
    senderLoad:URLVariables = new URLVariables();
        
    senderLoad.theName theName.text;
        
    senderLoad.theEmail theEmail.text;
        
    senderLoad.theMessage theMessage.text;

        var 
    req:URLRequest = new URLRequest('http://leebrimelow.com/mailExample/send.php');
        
    req.data senderLoad;
        
        var 
    loader:URLLoader = new Loader();
        
    loader.dataFormat URLLoaderDataFormat.VARIABLES;
        
    loader.addEventListener(Event.COMPLETEreceiveLoad);
        
    loader.addEventListener(IOErrorEvent.IO_ERRORloadFailed);
        
    loader.addEventListener(SecurityErrorEvent.SECURITY_ERRORloadFailed);
        
    loader.load(req);
    }

    function 
    receiveLoad(e:Event):void{
        if(
    'sentOk' in e.data && e.data.sentOk == true){
            
    gotoAndStop('success');
        } else {
            
    trace('PHP FAILURE: ' e);
            
    gotoAndStop('failed');
        }
    }

    function 
    loadFailed(e:Event):void{
        
    trace('COMMUNICATION FAILURE: ' e);
        
    gotoAndStop('failed');

    Please use [php] or [code] tags, and mark your threads resolved 8)

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    7
    Will do - hope this works :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center