One more question:
Lets say that in MyProxy I have 2 functions that call different methods from Delegate:
public function callDelegate1():void
{
var delegate : Delegate =new Delegate( this );
delegate.getData1();
}
public function callDelegate2():void
{
var delegate : Delegate =new Delegate( this );
delegate.getData2();
}
public function result( rpcEvent : Object ) : void
{
data = rpcEvent.result;
}
public function fault( rpcEvent : Object ) : void
{
data = new Object();
}
The Delegate class notifies MyProxy when data is retrieved. The result function is called. If different type of results are expected it's ok, I've resolved that by checking the rpcEvent.result type (one ArrayCollection and the other XML). Now comes the question:
If both functions from delegate class retrieve the same type of data ? How do I handle this ? I thought of something old school like having a property in MyProxy that is set to a specific value when a function is called from Delegate:
private var typeOfResult:String = "";
public function callDelegate1():void
{
var delegate : Delegate =new Delegate( this );
delegate.getData1();
typeOfResult = "getData1";
}
public function callDelegate2():void
{
var delegate : Delegate =new Delegate( this );
delegate.getData2();
typeOfResult = "getData2";
}
public function result( rpcEvent : Object ) : void
{
switch(typeOfResult){
case "getData1": ....
case "getData2": ....
}
}
If there is another approach let me know. thanks