User Guide

Table Of Contents
152 Chapter 8: Using Flash Remoting for Microsoft .NET
To return a session variable, you use the Flash.Result property, as shown in the following
example:
<%@ Page language="c#" debug="true" %>
<%@ Register TagPrefix="Macromedia" Namespace="FlashGateway"
Assembly="flashgateway" %>
<Macromedia:Flash ID="Flash" Runat="Server" />
<%
Flash.Result = session.myPreference;
%>
In the code, the value of the myPreference variable is assigned to the Flash.Result property,
which is returned to Flash. To set a session variable using a variable passed from Flash Remoting,
you use the
Flash.Params property, as shown in the following example:
<%@ Page language="c#" debug="true" %>
<%@ Register TagPrefix="Macromedia" Namespace="FlashGateway"
Assembly="flashgateway" %>
<Macromedia:Flash ID="Flash" Runat="Server" />
<%
if (Flash.Params.Count > 0)
{
session.myPreference = Flash.Params[0].ToString();
}
%>
In the code, the parameter passed from Flash is assigned into the myPreference session variable.
Using ASP.NET exception handling
To return custom ASP.NET exceptions to Flash, you use the
throw statement. You can throw
exceptions in the context of a
try/catch statement, an if/else statement, and so on. For
example, the following C# code fragment throws an exception:
if (Flash.Params.Count == 0)
{
throw new Exception("No arguments received.");
}
In the code, if the Flash.Params.Count variable is set to 0, an exception is thrown. The
exception message returns to Flash as part of the
FaultEvent object. To display the exception in
Flash, you use the
FaultEvent.fault.faultstring property, as shown in the following
ActionScript code fragment:
function serviceFunctionName_Fault (fe:mx.rpc.FaultEvent):Void {
textField = fe.fault.faultstring;
}
In the code, the fe.fault.faultstring property is assigned to the textField variable, which
represents a text field in the Flash application. If you want to display the stack trace information
returned from .NET, use the
FaultEvent.fault.detail property. For more information about
the FaultEvent object, see the FaultEvent class in Flash Remoting ActionScript Dictionary Help.