Accessibility
 
Home / Developer Center / Pet Market Application Center

Developer Center Article

Jason Hatcher
Macromedia
 
Best practices for using Macromedia Flash MX to build Rich Internet Applications
 

Macromedia is ushering in the next major innovation in client-side Internet content and applications with the introduction of Macromedia Flash MX. It was built from the ground up to provide a rich client environment for Internet content and applications. Flash MX will radically improve the quality of end-user applications, making the Internet more relevant and useful to businesses and consumers. Furthermore, Macromedia Flash MX expands from media and application interfaces into communications. This integration enables the richest applications on the Internet today.

Building web applications with Macromedia Flash MX
Macromedia Flash MX is the newest release in the Flash line of products. With Macromedia Flash MX, developers can create and deploy reliable web applications with unprecedented speed. This article describes some of the best ways developers can create high quality web applications.

·
Using Macromedia Flash Remoting
·
Organizing and storing server side code
·
Encapsulate client-server communication and services in an object
·
Group related UI functionality in movie clips and associate a class with the movie clip
·
Keep UI code as generic as possible
·
Store components in one central place
·
Other resources

Using Macromedia Flash Remoting

A new technology that can be used to link a Macromedia Flash MX client with a ColdFusion MX back-end is Macromedia Flash Remoting. This is the gateway technology that connects Macromedia Flash MX components on the client side with server-side application services. Flash Remoting enables a Flash MX client to seamlessly interface with remote components running on an application server in a fast, efficient, secure, and reliable way. Flash Remoting will ship as an integrated feature within ColdFusion MX and JRun 4 at no additional cost. Some of the advantages of using this technology are

·
Flash Remoting Components provide a single, simple, common approach to invoke server functionality from ActionScript, and a powerful NetConnection Debugger enabling end-to-end application debugging.
·
ColdFusion Components are accessible through Flash Remoting.
·
ColdFusion MX includes support for server-side ActionScript.
·
The Flash Remoting service is tightly integrated with ColdFusion MX security and session management.
·
Flash Remoting provides a robust, high performance transfer of data between Flash MX and remote objects using AMF, an optimized, light-weight message format that layers on HTTP.

Furthermore, the Flash Remoting service in ColdFusion MX can also be used with other server technologies, such as Java classes, EJBs, Mbeans,and .NET Framework languages like ASP.NET, VB.NET, and C#.

For more information on Flash Remoting, refer to the Macromedia Flash Remoting page.

 
Organizing and storing server side code

Developers should store their server side code in a package structure, similar to Java packages. Advantages of storing code in packages are

·
Packages help you better organize your code.
·
Packages give your server side code their own name spaces which will prevent your packages from being overwritten.
 
Encapsulate client-server communication and services in a class

Developers should encapsulate client side Flash remoting service invokers and service response handlers into one or more classes with the classes grouped by Flash remoting service components. This gives these benefits:

·
Class level encapsulation of the Flash remoting allows the client side code to be reused among multiple Flash movies. Since the code is shared, changes to the classes can be easily reflected among all the movies simply by republishing the movies.
·
Grouping the classes per component keeps the shared code smaller and purpose-based. Different movies only need to include the classes that implement the service calls the movie needs.
·
If additional listener/broadcaster code is added, this encapsulation can serve as a Model View Controller (MVC) architecture that dispatches server events to multiple client side UI elements.
 
Group related UI functionality in a movie clip and associate a class with the movie clip

In general, when an application uses a set of discrete UI elements to perform a single function, the elements should be grouped in a movie clip symbol and the symbol should be assigned an ActionScript class using #initclip and Object.registerClass in frame 1 of the movieclip. The advantages of this organization are:

·
You've created a reusable object complete with the associated code.
·
#initclip guarantees the class initialization code automatically executes exactly once and that the code does not execute until the UI elements are on the stage.
·
Your class will provide a uniform API for all manipulating the UI elements that perform the function.
·
The complexity in the UI interactions is hidden behind a simple API.
 
Keep UI code as generic as possible

When building function-based UI elements, avoid code that depends on specific paths or other parts of the application. If your element needs to interact with other function-based UI elements, consider using a Controller-based approach that acts as an intermediary between the UI elements.

 
Store components in one central place

For ColdFusion MX components, developers should store their components in one central place. Storing them in one central place makes your code more usable and maintainable. Furthermore, developers should never place their components, and what ever uses their components, in the same directory.

 
Other resources
·
Read the ActionScript Best Practices article below.
·
Do not place functions on the timeline.
·
Create server side components and create a package directory structure.

Browse the following links to learn more about how you can use Macromedia Flash MX to provide an unparalleled environment in terms of richness of content, media, and application interface elements for your web applications.

ActionScript Coding Best Practices
The foundation of a good application is clean and coherent code. Learn how to standardize your ActionScript code in this white paper.

Flash Application Design
This article explains how to build data-driven Flash applications. Includes downloadable Flash files and Perl scripts.

Macromedia Flash MX: Better Interfaces for Web Applications
Put your users first. Find out how Macromedia Flash interfaces make web experiences smoother.

Creating components in Macromedia Flash MX
This article explains how to create a component in Macromedia Flash MX, including:

·
Defining parameters
·
Adding a description
·
Creating a custom interface and a Live Preview

Creating forms with UI components in Macromedia Flash MX
Learn how to create a simple order form using the Flash UI components in Macromedia Flash MX, and how to submit the form data using the new LoadVars ActionScript object.

Implementing XML and Flash in a Web application
Read this example-driven article to learn more about creating a client-server application that supports data transfer and real-time continuous connections using Macromedia Flash 5 with XML as your application protocol.

Google query on the Model View Controller (MVC) architecture
The MVC architecture is a way of organizing GUI code in order to make it easy to extend and reuse.

 

 

Jason Hatcher is an Instructional Media Development (IMD) Manager at Macromedia and a member of the Sitespring engineering team. He has written documentation for Sitespring, Macromedia Flash MX, and the Macromedia Pet Market blueprint application.