Introduction

When we speak of Flash movies interacting with one another, there are two types of interactions. First, there are interactions between movies that are running on the same computer. And second, there are interactions between movies on different computers.

Prior to Flash MX, the only way to communicate between movies on the same computer (without using server-side functionality) was to use the fscommand( ) global function, which executes JavaScript methods. Unfortunately, these methods were both cumbersome to use and not always reliable (due to lack of support in various browsers). Also, these methods worked only with Flash movies running in web browsers in which the browser windows had references to one another. However, Flash MX introduced local connections?a means by which any Flash movie can broadcast to and listen for broadcasts from any other movie on the same computer. The advantages of local connections are:

  • They are relatively simple to use.

  • They are implemented entirely in ActionScript, and they work for movies running in Flash Player 6 or later.

Additionally, prior to Flash MX, the only way to communicate between movies on different clients was to use a socket connection via the XMLSocket class. While the XMLSocket class is still a valuable and powerful technology, it has its disadvantages:

  • Using sockets requires a server-side socket server. Although creating your own socket server requires proficiency in a server-side programming, third-party socket servers, such as Unity (http://moock.org/unity) are widely available and make working with the socket server considerably easier.

  • The XMLSocket class does not have a very robust feature set. XMLSocket objects allow users to send data to a socket server and listen for data from a socket server. Additional code is necessary to handle that data in a meaningful way.

Using Flash Player 6 in conjunction with Flash Communication Server MX (FlashCom), it is possible to create communication between client movies without relying on the XMLSocket class. The advantages of FlashCom are:

  • It provides a standardized way of implementing communication between clients.

  • It provides a rich API, and it automatically serializes and deserializes datatypes.

  • It is capable of much more than just creating channels of communication between client movies. You can also use FlashCom for audio and video recording, playback, and live broadcasts. Socket servers don't offer this kind of functionality.

At the same time, you should take into consideration that there are possible disadvantages to FlashCom:

  • FlashCom costs money; however so do many professional socket servers. Furthermore, a developer version of FlashCom server is freely available for testing, and the personal edition of FlashCom server is bundled with Director MX.

  • FlashCom may not perform as well as socket servers when it comes to a large number of connections or high volumes of data transfer. Do some research and testing to determine whether FlashCom's performance characteristics meet the needs of your application.

See Also

See Chapter 14 for FlashCom recipes. See http://www.macromedia.com/software/flashcom for more information on FlashCom and its pricing. Third-party socket servers of varying price and capability include moockComm (http://www.moock.org/chat/moockComm.zip), Unity (http://moock.org/unity), aquaServer (http://www.figleaf.com/development/flash5/aquaserver.zip), Fortress (http://www.xadra.com/products/fortress/fortress_faqs.html), and ElectroServer (http://www.electrotank.com/ElectroServer).



    Part I: Local Recipes
    Part II: Remote Recipes