WebService

  • Language Version: ActionScript 3.0
  • Runtime Version: AIR 1.0, Flash Player 9+
  • Description: WebService Class creates an URLLoader instance and allows the send/get of data from a WSDL
  • Version: 1.0.0
  • Author: Cameron Tullos
  • [download]
  • properties | methods | usage

 

Public Properties

loader | request | url | method | vars

  • loader:URLLoader refers to the URLLoader instance of the WebService. Listeners can be attached to this object to dispatch events. loader is not available until load has been called (see: URLLoader for details)
  • request:URLRequest refers to the URLRequest instance of the WebService. Listeners can be attached to this object to dispatch events. request is not available until load has been called (see: URLRequest for details)
  • url:String the path to the WSDL
  • method:String [POST|GET] the http request method of the WSDL
  • vars:Object the REST based variables the WSDL is listening for
  •  

    Public Methods

    load

  • load(): initiates the WSDL
  • See TextField

     

    Usage

     

    example:
    /* 
        Drag an instance of the Button component, TextInput component (3), and TextArea component to the stage
        Name them: sender, email, subject, message, sendBtn
    */
     
    import flash.events.MouseEvent;
    import WebService;
     
    sendBtn.addEventListener(MouseEvent.CLICK, sendMail);
     
    function sendMail(event:Event) { 
    	var parms:Object = {
    		email: email.text,
    		message: message.text,
    		name: sender.text,
    		subject: subject.text
    	};
     
    	var ldr:WebService = new WebService('http://www.illumifi.net/contact.php', 'POST', parms);
    	ldr.loader.addEventListener(Event.COMPLETE, sendComplete);
    	ldr.load();
     
    	function sendComplete(event:Event) {
    		var loader:URLLoader = URLLoader(event.target);
    		email.text = '';
    		message.text = '';
    		sender.text = '';
    		subject.text = '';
     
    		confirm.text = (Number(loader.data) == 1) ? 'Your message has been sent' : 'ERROR: Unable to send message';
    	}// end sendComplete()
    }
    // end sendMail()


    You must be logged in to post a comment.