Not so helpful

Jan. 23, 2007 4 Comments Posted under: ActionScript, Development, Flex

I have recently been looking at some action script and have found the support on the web and through Adobe a little limited..

Perhaps this is coming from open web languages which have a tonn of online support and examples, but have a look at this explination of a webservice….



import mx.rpc.soap.WebService;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
private var ws:WebService;                          

public function useWebService(intArg:int, strArg:String):void {
ws = new WebService();
ws.destination = "wsDest";
ws.echoArgs.addEventListener("result", echoResultHandler);
ws.addEventListener("fault", faultHandler);
ws.loadWSDL();
ws.echoArgs(intArg, strArg);
}              

public function echoResultHandler(event:ResultEvent):void {
var retStr:String = event.result.echoStr;
var retInt:int = event.result.echoInt;
//do something
}
public function faultHandler(event:FaultEvent):void {
//deal with event.fault.faultString, etc.
}         

Firstly there it’s a useless example as it does nothing, there is no way to test it and check it is working, the values to the variables are even less verbose than the variables themselves.

For example ws.destination = “wsDest”; what the hell is meant to go here, it takes no URLs claiming Unknown destination.

Any ideas?

This entry was posted on Tuesday, January 23rd, 2007 at 7:08 pm and is filed under ActionScript, Development, Flex. You can leave a comment and follow any responses to this entry through the RSS 2.0 feed.

4 Comments Leave a comment

  1. Dark0 24 January 2007 at 10:45 am #

    Don’t eat yellow snow.

  2. Rob 26 January 2007 at 3:44 pm #

    It turns out you dont need the ws.destination = “wsDest”; line at all, still no idea what it would be used for though.

  3. greg 13 March 2007 at 5:18 pm #

    that is daft and way more complex than:

    import mx.services.*;
    var W:WebService = new WebService(“http://path/to/service.php?wsdl”);

    var C:PendingCall = W.methodName(“your”, “args”, “here”);
    C.onResult = function (r) {
    trace(“RESULT : “+r);
    for (var i in this) {
    trace(i+” :: “+this[i]);
    }
    };

    C.onFault = function (f) {
    trace(“ERROR : “+f);
    for (var i in this) {
    trace(i+” :: “+this[i]);
    }
    };

  4. Rob 13 March 2007 at 9:22 pm #

    Thanks Greg, although the use of verbose variable names must have been excused on your example ;)

    Seems like the more I use AS the more of get used to the way things work and where to look for help, although examples seem harder to come by :(

Leave a Reply