1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| import flash.events.Event;
import flash.events.EventDispatcher;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.RemoteObject;
public class Toto extends EventDispatcher
{
public var _errorMessage:String;
public var _remote:RemoteObject;
public var classList:Object;
public var activeClass:String;
public function Toto()
{
activeClass = 'voiture';
classList = new Object();
classList['voiture'] = new Voiture();
_remote = new RemoteObject();
_remote.destination = "amfphp";
_remote.source = "lien.vers.source";
}
//Class callRemote
public function callRemote(callFunction:String, returnFunction:String, failFunction:String, ... args):void
{
// Déclenchement des évènement en cas de réussite ou d'échec de l'appel AMFPHP
_remote[callFunction].addEventListener(ResultEvent.RESULT, classList[activeClass][returnFunction]);
_remote.addEventListener(FaultEvent.FAULT, failCall);
// (1) Appel de la fonction dynamique : ne marche pas
var nbArgs:uint = args.length;
switch (nbArgs)
{
case 0 : _remote[callFunction]();
case 1 : _remote[callFunction](args[0]);
case 2 : _remote[callFunction](args[0], args[1]);
case 3 : _remote[callFunction](args[0], args[1], args[2]);
}
// (2) Appel de la fonction en dur : fonctionen très bien
_remote.initSession(args[0]);
} |
Partager