User Guide
Table Of Contents
- Contents
- About Flash Remoting
- Getting Started
- Using Flash Remoting ActionScript
- Using the RemotingConnector component (Flash Professional only)
- Using Flash Remoting Data in ActionScript
- About Flash Remoting and data types
- Understanding Action Message Format
- Converting from ActionScript to application server data types
- Converting from application server data types to ActionScript
- ColdFusion to ActionScript data conversion issues
- About working with objects
- About working with RecordSet objects
- About working with XML
- The NetConnection Debugger
- Using Flash Remoting with ColdFusion MX
- Using Flash Remoting for Java
- About Flash Remoting for Java
- Calling Java classes or JavaBeans from ActionScript
- Calling Enterprise JavaBeans (EJBs) from Flash
- Calling servlets and JSPs from Flash
- Calling JMX MBeans from Flash (JRun only)
- Calling server-side ActionScript from Flash (JRun only)
- Handling function results in ActionScript
- Using Flash Remoting with JRun security
- Passing XML objects between Flash and Java
- Viewing Flash Remoting log entries
- Using Flash Remoting for Microsoft .NET
- Flash Remoting for Microsoft .NET
- Calling ASP.NET pages from Flash
- Making an ASP.NET page available to Flash Remoting
- Getting a reference to an ASPX-based service in ActionScript
- Invoking ASPX pages in ActionScript
- Using the Flash Remoting custom server control in ASPX pages
- Using the Flash Remoting namespace in code-behind files
- Using ASP.NET state management with Flash Remoting
- Using ASP.NET exception handling
- Using ADO.NET objects with Flash Remoting
- Displaying a RecordSet object in Flash with ActionScript
- Calling web services from Flash
- Calling ASP.NET assemblies from Flash
- Viewing Flash Remoting log entries
- Using NetServices and Connection Classes
- Index

40 Chapter 2: Using Flash Remoting ActionScript
For example, to create a service object for the Macromedia Pet Market catalog web service, specify
a line similar to the following:
petMarketCatalogService = gatewayConnection.getService("petmarket.api.
catalogservice”, this);
Authenticating a user to the application server
In some cases, your application server might require you to provide user authentication—a user
name and password—before you can use a service.
Flash Remoting provides the
setCredentials() method of the Connection object to allow you
to specify authentication credentials to send to the application server. Flash Remoting sends the
credentials in the header of every service function call. This method is currently supported on the
following servers:
• ColdFusion MX
• JRun 4
To use the
setCredentials() method, call the method after you have created the gateway
connection and before you call a service function. For a Flash application that is run by a single
user during a session, you can call the
setCredentials() method any time after creating the
gateway connection object. If you created the gateway object using the Service object, you can
access the connection object through the
connection property and call setCredentials() to
provide authentication, as shown in the following example:
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.rpc.RelayResponder;
import mx.rpc.ResultEvent;
import mx.rpc.FaultEvent
function getCategories_Result (re:ResultEvent):Void {
trace("Got Categories - " + re.result.length + " Record" + (re.result.
length>1?"s":""));
}
function getCategories_Fault (fault:FaultEvent):Void {
trace("CategoriesCallFailed-" + fault.fault.description);
}
var myResponder:RelayResponder = new
RelayResponder(this,"getCategories_Result","getCategories_Fault");
var petMarketService:Service = new Service(//establish connection
"http://examples.macromedia.com/flashservices/gateway",
null,
"petmarket.api.catalogservice",
null,
myResponder );
// set user credentials
petMarketService.connection.setCredentials("myUserName","myPassword");
// call service function
var temp_pc:PendingCall = petMarketService.getCategories("en_US");
Note: To ensure security, never include specific user names or passwords in ActionScript.