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

5.2. What Does It Look Like?

The FrontController class is located in the com.adobe.cairngorm.control package. The code for this class looks as follows:

package com.adobe.cairngorm.control { import com.adobe.cairngorm.CairngormError; import com.adobe.cairngorm.CairngormMessageCodes; import com.adobe.cairngorm.commands.ICommand; import flash.utils.Dictionary; import flash.utils.describeType; import flash.utils.getQualifiedClassName; public class FrontController { protected var commands : Dictionary = new Dictionary(); public function addCommand( commandName : String, commandRef : Class, useWeakReference : Boolean = true ) : void { if ( commandName == null ) throw new CairngormError( CairngormMessageCodes.COMMAND_NAME_NULL ); if ( commandRef == null ) throw new CairngormError( CairngormMessageCodes.COMMAND_REF_NULL ); if( commands[ commandName ] != null ) throw new CairngormError( CairngormMessageCodes.COMMAND_ALREADY_ REGISTERED, commandName ); if ( implementsICommand( commandRef ) == false ) throw new CairngormError( CairngormMessageCodes.COMMAND_SHOULD_IMPLEMENT_ICOMMAND, commandRef ); commands[ commandName ] = commandRef; CairngormEventDispatcher.getInstance().addEventListener( commandName, executeCommand, false, 0, useWeakReference ); } public function removeCommand( commandName : String ) : void { if ( commandName === null ) throw new CairngormError( CairngormMessageCodes.COMMAND_NAME_NULL, commandName); if ( commands[ commandName ] === undefined ) throw new CairngormError( ...

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