[swx] SWX Object exists, but call isn't executed

Mediactief - Paul de Raaij paul at mediactief.nl
Mon Apr 14 09:00:14 PDT 2008


Wow, thanks!

It's my first dynamic project in Flash so I have a lot of trouble to use it
the right way, but I've ordered some books to learn it the proper way.  


Met vriendelijke groet,

Mediactief
Paul de Raaij

Moddermanplein 10
2675 CT Honselersdijk

T: 0174-642451
M: 06-55797329
E:  paul at mediactief.nl
W: www.mediactief.nl
W: www.mediactief.eu 


The information in this e-mail message (including any information contained
in attachments hereto) is intended only for use of the addressee. This
e-mail message contains confidential or privileged information. If you
receive this e-mail message unintentionally, please notify the sender
immediately and then delete this message. E-mail transmission is not
guaranteed to be secured or error free. The sender is in no way liable for
any errors or omissions in the content of this e-mail message, which may
arise as a result of e-mail transmission 

-----Oorspronkelijk bericht-----
Van: swx-bounces at osflash.org [mailto:swx-bounces at osflash.org] Namens
Nederflash (Folkert Hielema)
Verzonden: maandag 14 april 2008 17:56
Aan: SWX Mailing List
Onderwerp: Re: [swx] SWX Object exists, but call isn't executed

You should really use the SWX actionscript api and with that you best use a
SWXService singleton class.
Wherever you need swx you just call the SWXService.getInstance();

Your singleton class would only hold the information you want at hand (see
below), any dynamic stuff you send through the call like this basic
usage:

var service = SWXService.getInstance();
var data = {};
data['service'] = "Twitter";
data['type'] = "userTimeLine";
data['command'] = this;
data['args'] = [ user,pass,friendID,20,null ] service.swxCall(data);

where data['command'] takes care of the reference to the place you have this
script for onResult and onFault handlers.
That way your inplace error and resultHandlers which will automatically be
called from your SWXService singleton class. just put your onResult and
onFault at the place you do the swxCall.

Within the SWXService singleton class needs 4 methods basically which are
getInstance(),swxCall(), onResult and onFault (maybe onTimeout also)

the SWXService class has a few vars and sets a few defaults so class may
look like:
//////////file SWXService.as//////////
import org.osflash.SWX;
class SWXService {
   static var instance:SWXService=null;
   var swx:SWX;//instance of the real SWX
   private var gatewayURL:String = "http://mygateway.com/php/swx.php";
   private var debug:Boolean = true;//false for production
   var methodParams:Object;
   private var defaultService:String = "SomeService";
   private var defaultEncoding:String = "GET";
   //commandTarget, reference to callback onResult or onFault
   private var commandTarget;//untyped path back to where call was from
   public function SWXService()
   {
     swx = new SWX  ;
     swx.gateway = this.gatewayURL;
     swx.encoding = this.defaultEncoding;//overwrite when needed
     swx.debug = this.debug;
   }
   public static  function getInstance()
   {
     instance = (instance != null) ? instance : new SWXService();
     return instance;
   }
   public function onResult(eventObj)
   {
     commandTarget.onResult(eventObj.result);
   }
   public function onTimeOut(eventObj)
   {
     eventObj.description="WARNING SWXService timedOut try again later";
     commandTarget.onFault(eventObj);
   }
   public function swxCall(data)
   {
     //set up method parameters as there dynamic
     swx.encoding = (data.encoding != undefined) ? data.encoding : 
defaultEncoding;
     commandTarget = data.command;
     var service:String = (data.service!=undefined) ? data.service : 
defaultService;
     methodParams={
       serviceClass:service,
       method:data.type,
       args:data.args,
       result:[this,onResult],
       timeout:[this,onTimeOut]
     };
     swx.call(methodParams);
   }
}
//////////end file SWXService.as//////////

Something in the lines of this would help you greatly to reduce root based
calls like you do in your examples.

hope that helps,

Folkert




_______________________________________________
swx mailing list
swx at osflash.org
http://osflash.org/mailman/listinfo/swx_osflash.org





More information about the swx mailing list