20.9. Calling ASP.NET Functions from Flash

Problem

You want to call ASP.NET service functions using Flash Remoting.

Solution

Use ASP.NET pages (which requires modifying the code) or, preferably, use public DLL methods (which requires no modification).

Discussion

You can call ASP.NET pages or public DLL methods as service functions from a Flash movie using Flash Remoting.

Ideally, DLL methods should be used in place of ASP.NET pages when it comes to Flash Remoting. Although some people may have hesitancy about writing/using DLLs because they require compilation, they are far more advantageous than using ASP.NET pages. Any public method of an ASP.NET DLL can be called using Flash Remoting without any modification to the DLL code. Furthermore, using DLLs allows you to separate your business logic from your presentation logic, so the same DLL can be used by multiple interfaces (Flash movies, ASP.NET pages, Windows Forms, etc.). Using DLLs for your business logic is a best practice regardless of whether you are using Flash Remoting.

To call a DLL method from a Flash movie, you should place that DLL in the web application’s bin directory and create a service object that maps to the class within it. The correct service name to use is the fully qualified class name, which must include the namespace. For example:

// Create a service object that maps to the Book class in the OReilly.ASCB namespace.
myService = myConnection.getService("OReilly.ASCB.Book");

// Call the getTitle(  ) method of the  ...

Get Actionscript Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.