O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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  ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required