Groups | Blog | Home
all groups > macromedia flash flash remoting > july 2004 >

macromedia flash flash remoting : RelayResponder and events


vlgvlg
7/16/2004 1:05:57 AM
Hello

I am new to Flash Remoting and Flash 2004 pro so probably my question will
sound stupid but anyway.

I am trying to develop a simple Flash 2004 Pro app with data coming From Ms
SQL Server via Flash Remoting for .NET. I have built a form with DataGrid and
started playing with the code. When I place the script that connects to the
service and populates the DataGrid in Layer1:1 frame without any event handlers
like ?load?, everything works fine. If I put the same script inside any kind of
event: ?load? for the screen or ?click? for a button I am not getting anything
from RelayResponder. Basically neither result nor fault handlers of my
RelayResponder fire when data is received (checked in the NetConnection
Debugger). Am I doing something wrong?

function whenClicked() {
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.rpc.RelayResponder;
import mx.rpc.ResultEvent;
import mx.rpc.FaultEvent;
import mx.remoting.RecordSet;
mx.remoting.debug.NetDebug.initialize();
var aspxService:Service = new
Service("http://localhost/flashremoting/gateway.aspx", null,
"flashremoting.test", null, null);
var pc:PendingCall = aspxService.getUsersList();
pc.responder = new RelayResponder(this, "gotResources", "gotResourcesFault");

function gotResources(re:ResultEvent):Void {
var rs:mx.remoting.RecordSet = mx.remoting.RecordSet(re.result);
rs.setDeliveryMode("onDemand");
this.gridUsersList.dataProvider = rs;
this.gridUsersList.selectedIndex = 0;
}
function gotResourcesFault(fe:FaultEvent):Void {
mx.remoting.debug.NetDebug.trace({level:"Debug", message:"Error Getting
Resources"});
}
}
this.ShowAllUsers_cmd.addEventListener("click", whenClicked);

Thanks in advance for any help.
Vlad

vlgvlg
7/16/2004 1:45:39 AM
OK, I finally found the solution (it took me almost two days before and 20
minuted after I posted my question on this forum LOL). You declare Service and
RelayResponder in the script outside any events. In the event handler you only
call the service:

function whenClicked() {
var pc:PendingCall = aspxService.getUsersList();
}
this.ShowAllUsers_cmd.addEventListener("click", whenClicked);

It is extremely disappointing that nothing in the manuals or documentation for
Flash 2004 Pro or Flash Remoting covers this and many other basic situations.
Considering that Flash Pro is being aimed to application developers this should
not be the case.
AddThis Social Bookmark Button