Welcome!

.NET Authors: Liz McMillan, Peter Silva, Yakov Werde, Matthew Pollicove , Corey Roth

Related Topics: .NET

.NET: Article

Flash ASP.NET

Dynamic interactive medium for Web applications

FlashVars
FlashVars are a method of communicating between ASP.NET and Flash that uses tags embedded in HTML to exchange data. FlashVars only allow for one-way communication - from the server to the Flash Movie. Because of this, FlashVars aren't an alternative for applications that require data to be sent from a client-side application to a Web server, such as an e-mail form. FlashVars, however, are a very fast and efficient form of communication and are often overlooked in circumstances where small amounts of data have to be sent to a Flash Movie (see Figure 1).

FlashVars are unique among the exchange methods in that the data they contain is sent along with the .swf file when requested by a client browser instead of in a separate load after a Flash movie is loaded. This kind of exchange is less obtrusive to the user than other methods and is a good solution in certain circumstances.

LoadVars
The LoadVars object is much more versatile than FlashVars in terms of the direction and amount of data that can be exchanged. The LoadVars object is capable of either sending data to the server for processing, loading data from the server, or sending data to the server and waiting for a response back from the server in one operation. The LoadVars object uses name-value pairs to exchange data between the client and the server. The LoadVars object is best used in a scenario that requires two-way communication between the Flash Movie and server-side logic, but doesn't require large amounts of data to be passed. The LoadVars object requires that the .NET developer handle the formatting of the exchanged data - potentially a real pain, depending on the amount you intend to pass (see Figure 2).

XML Object
The Flash XML Object is another option for communicating between a Web server and Flash client. The XML object is very similar to the LoadVars object in functionality in that it can both send data to the Web server and get data from it. The difference between the XML object and the LoadVars object is the format in which the data being sent and received is formatted. Whereas the LoadVars object expects a name-value pair as a response, the XML object sends and receives a well-formatted structured XML document. Structured XML data makes the XML object much more suitable than the LoadVars object for handling larger amounts of data (see Figure 3).

Web Services
Introduced with Flash MX 2004 Processional Edition, Web Services are the newest method for communicating between Flash and ASP.NET. Web Services use SOAP (Simple Object Access Protocol), an XML-based format, to transfer data between the client and server. Web Services are an industry standard for exposing proprietary "services" for others to use in their applications. An example of a web Service is the search method offered by Google. By using this method through Web Services, it's possible for you to make a Flash application that uses the Google search engine. As mentioned earlier, Web Service creation is very easy with ASP.NET, making it an excellent choice for Flash applications. (Figure 4)

Flash Remoting (Figure 5) is the most powerful and versatile of the options for communicating between a Flash movie and a .NET Web server. Using Flash Remoting, it's possible to access data directly from an ASP.NET Web application in a secure, quick, and efficient way. Flash Remoting uses a binary message format for transferring messages between the Flash client and server-side ASP.NET code called ActionScript Messaging Format, or AMF. AMF, like any of the other methods, travels between the client and server over HTTP, so you don't have to worry about security mechanisms (such as firewalls) interfering with your communication. Although modeled on the same protocol as Web Services, AMF is much more lightweight than the other communication options, and therefore travels much more quickly than calls using the Web Service connector. AMF is also securable using SSL, so it's a great option for security-sensitive applications. Using Adobe's version of Flash Remoting does come with a price tag, however. Flash Remoting for ASP.NET is a standalone server-side component not included with Flash MX 2004, which costs $999 per Web server. Thankfully, there's an Open Source alternative to the Adobe Flash Remoting for .NET package called Fluorine. Fluorine is an Open Source Flash (www.osflash.org) project and is available for download at http://fluorine.thesilentgroup.com/.

Flash & ASP.NET Resources
www.flashasp.net

The information I've covered in this article is just a brief overview of the world of Flash development with ASP.NET. I have recently written a book published by Friends of Ed called Foundation ASP.NET for Flash, which thoroughly covers all of the Flash-ASP.NET communication methods mentioned above, as well as a step-by-step introduction to ASP.NET development with C# and Visual Studio.NET. I encourage you to pick up a copy and add yourself to the growing community of Flash-ASP.NET developers. You'll also find a growing source of Flash and ASP.NET resources, as well as a support forum on the Foundation ASP.NET for Flash homepage at www.flashasp.net.

More Stories By Ryan Moore

Ryan Moore is the lead software architect and a principal of Balance Studios Inc. (www.balancestudios.com) as well as epicsoft, Inc. (www.epicsoft.net) of Green Bay, WI. Ryan is a C# programmer and Certified Macromedia Flash Developer. Ryan currently maintains a weblog at http://blogs.ittoolbox.com/c/engineering/

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
craig 05/20/06 04:27:19 PM EDT

There are points in this article that are inaccurate. I could be wrong, but my understanding of ACtionScript is that it is really similar to Javascript. Javascript, ActionScript and C# all do have that similar c-based syntax, but that is where the similarity ends. Where C# and Java are class based, object-oriented, strongly typed compiled languages, Javascript and actionscript are loosely typed, prototype based, languages. C# and Java are similar, but neither are very similar to ActionScript or Javascript. In fact, Javascript's name was made to sound like Java for marketing reasons only -- its philosophical underpinnings and practical usage is actually quite different. Its been a while since I did Flash development but I understood ActionScript to be more similar to Javascript. For example, does ActionScript have inheritence or interfaces? Is it strongly typed? Do you create classes? I think the answer to all these questions is "NO".

Secondly, JScript is NOT the .NET version of Java. That's J#. J# has a very similar syntax and API to Java and it Microsoft's attempt to make porting Java programs to .NET easier. JScript on the other hand, is the Microsoft version of Javascript and is not widely used. You can use it in .NET on the server, or on the IE browser as a client side replacement for Javascript.