FireworksColdFusionDreamweaverFreehandFlashMXHome
Latest New Content

Latest Free Content
View All
Free Content
Accessibility
CMX Learning Guides
Hosted by enterhost

Anatomy of a Central Application - Part 1

By: Paul Newman

Page 1 of 4

Set for printing

Next

You have to admit, there's a certain "gee whiz" quality about Macromedia Central. The Central components are much slicker than the V1 components released for Flash MX, and even Flash MX 2004 doesn't have an accordian tab component. But Flash is not just about cool Flash intros (ugh) or rich user interfaces anymore. With the emergence of Central and Flex, Flash has become an incredibly practical and efficient means of retrieving, storing, and displaying information.

Sometimes, the best way to learn is by example. That's why we've decided to release the complete source code for our Central application, Community MXtra. In this two-part article, I'll examine some of the key features of CMXtra and explain how certain effects were achieved. You'll learn about agents, pods, interfaces, tooltips, Flash Remoting, the WebService object, LCService, LCDataProvider, Shared Objects, custom data grids, and much more. To obtain the source code, click Downoad Support Files at the bottom of this page. I encourage you to poke around the files to familiarize yourself with the application. If you're new to Central, you might want to read "Your First Central App" before proceeding.

CMXtra: The Big Picture

The CMXtra application enables users to search for articles on CommunityMX.com, browse content using a calendar, and maintain a list of favorites. Because Central is authored using Flash and ActionScript 1.0, it's fairly easy to migrate existing apps to Central.

TIP: Many of the Central components will look familiar to Flash developers (DataGrid, ComboBox, PushButton, ScrollPane, etc.). Keep in mind, however, that because Central is currently an ActionScript 1.0 solution, its component methods correspond to the V1 components for Flash MX — not the V2 components for Flash MX 2004. The V1 components were distributed with the Flash UI Component sets 1 through 5.

In other words, if you can create apps for Flash, you can create apps for Central. The Central API introduces new components and classes, as well as functions required to initialize various parts of the application (agent, pods, etc.). Once you get up to speed on the Central API, developing Central apps is fairly straightforward.

Figure 1 - CMXtra is comprised of an app, and agent, and two pods
 Figure 1  CMXtra is comprised of an app, and agent, and two pods (enlarge)

The CMXtra application consists of four FLA files and eight ActionScript files:

File Description

Application (Client)   The main application that is loaded into the Shell

FLA icon cmxtra.fla

  • Includes the following components: AccordianTab, Calendar, DataGrid, DialogBox, IconButton, PushButton, ScrollPane, TextInputField.

ActionScript iconcmxtra.as

  • Consists of button and event handlers, utility functions (showDialog, updateStatus), functions to add and remove favorites, and code to initialize and call the Flash Remoting service.
  • Callable LCService Client functions: gCom.formatSearchResult, gCom.setQuery.

ActionScript iconinit.as

  • Contains required Central initialization functions such as onActivate, getMaximumSize, getMinimumSize.
  • Creates LCService Client instance (gCom) and LCDataProvider Client instances (gFavorites, gLastSearch).
 

Favorites Pod (Client)   Enables user to view or remove favorites from the Console

FLA icon favePod.fla

  • Includes the following components: DataGrid, IconButton, TossButton.

ActionScript iconfavePod.as

  • Contains event handlers, utility function, and required Central functions such as onActivate.
  • Creates an LCDataProvider Client instance (gFavorites).
 

Search Pod (Client)   Enables user to search CMX and add favorites from the Console

FLA icon searchPod.fla

  • Includes the following components: DataGrid, IconButton, PushButton, TextInputField, TossButton.

ActionScript iconsearchPod.as

  • Contains event handlers, utility functions (doSearch, enableIcons), and required Central functions such as onActivate.
  • Creates LCService Client instance (gCom) and LCDataProvider Client instances (gFavorites, gLastSearch).
  • Callable LCService Client functions: gCom.formatSearchResult, gCom.setQuery.
 

Agent (Server)   Handles communication among application and pods

FLA icon agent.fla

  • Contains no graphic elements. This "headless SWF" is simply a container for the ActionScript in agent.as.

ActionScript iconagent.as

  • Contains required Central initialization functions such as onActivate, getMaximumSize, getMinimumSize.
  • Defines agent as the LCService Server (gCom) and LCDataProvider Server (gFavorites, gLastSearch).
  • Instantiates the WebService object used to search Community MX.
  • Callable LCService Server functions: gCom.searchContent, gCom.getQuery.
 

Favorites  Saves favorites to disk using Shared Object

ActionScript iconfavorites.as

  • Initializes gStorage Shared Object.
  • Contains three functions: initStorage, saveFavorites, deleteStorage.
 

Shared  Functions and global methods shared by the app, agent, and pods

ActionScript iconfunctions.as

  • Contains a single function: formatDate.

ActionScript iconinterface.as

  • Defines global methods for the LCService object.

The app, in the context of this article, is the SWF file that's loaded into the Shell (see Figure 1). The agent is a "headless SWF" — one without any graphic elements — that you can use to retrieve and store data. By centralizing your data services and global methods in an agent, you can use it to broadcast events and trigger updates in your app and pods. The pod is a smaller SWF file that's usually a miniaturized or condensed version of the main app. Pods enable users to access the core functionality of your main app without consuming as much desktop real estate.

I know this seems like an awful lot of files for a relatively simple application, but keep in mind that most of these files are required to implement the pods. Without the pods, the CMXtra app can be generated with two files: cmxtra.fla and cmxtra.as.

Page 1 of 4 1 2 3 4 Next


download
Download Support Files


Keywords
macromedia central, cmxtra, flash mx 2004, LCService, LCDataProvider, data grid, ActionScript, accordian tab, shared object