148
Chapter 8: Using Flash Remoting for Microsoft .NET
function gotResourcesFault( fe:mx.rpc.FaultEvent ): Void {
trace( "error occurred"+ fe.fault.faultstring );
}
The gateway URL must reference an ASPX page inside the application directory. You should
use the gateway URL only during development in the Flash authoring environment. When
you deploy the Flash application, you should supply the gateway URL using a parameter in the
HTML that embeds the SWF file in the web page. For more information on supplying the
gateway URL in a web page, see
“Specifying the gateway connection in a web page”
on page 38
.
You must provide the fully qualified path to the directory that contains the page that you want
to invoke.
Invoking ASPX pages in ActionScript
After you have a reference to the ASPX page, you can use ActionScript functions to invoke it. For
example, the following ActionScript code invokes the ASPX page GetResources.aspx, assuming
that aspxService represents your reference to the directory that contains the ASPX page:
var pc:PendingCall = aspxService.GetResources();
The ASPX page's filename, GetResources.aspx, becomes the function name,
GetResources()
.
This is the complete example:
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.rpc.RelayResponder;
import mx.rpc.ResultEvent;
import mx.rpc.FaultEvent;
var aspxService:Service = new Service( "http://localhost/flashremoting/
gateway.aspx", null, "flashremoting.samples", null, null );
var pc:PendingCall = aspxService.GetResources();
pc.responder = new RelayResponder( this, "gotResources", "gotResourcesFault"
);
function gotResources( re:mx.rpc.ResultEvent ):Void {
trace( "got resources-"+ re.result );
}
function gotResourcesFault( fe:mx.rpc.FaultEvent ): Void {
trace( "error occurred"+ fe.fault.faultstring );
}