O'Reilly logo

Professional Cairngorm™ by Jeremy Wischusen

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

7.3. How Do You Create One?

You create commands by implementing the ICommand interface, and if necessary the IResponder interface. Commands are generally created in a command package and the naming convention is to prefix the word command with something descriptive about what the command does.

The following example creates a command that implements both the ICommand and IResponder interfaces. When creating such a command, there are a couple of things that you want to do in the New ActionScript Class dialog shown in (Figure 7-1). (Make sure the "Generate functions inherited from interfaces" box is checked.)

Figure 7.1. Figure 7-1

First, click the Add button next to the Interfaces field. In the Open Type dialog select the ICommand interface, as in (Figure 7-2).

Figure 7.2. Figure 7-2

Repeat these steps and select the IResponder interfaces, as in (Figure 7-3).

Figure 7.3. Figure 7-3

The resulting class should look something like the following:

package com.cairngormexample.commands { import com.adobe.cairngorm.control.CairngormEvent; import mx.rpc.IResponder; import com.adobe.cairngorm.commands.ICommand; public class ExampleCommand implements ICommand, IResponder { public function ...

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