/*----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is Fever Framework code. The Initial Developer of the Original Code is Romain Ecarnot. Portions created by Initial Developer are Copyright (C) 2006 the Initial Developer. All Rights Reserved. Contributor(s): Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------------*/ import com.bourre.events.BasicEvent; import com.bourre.events.EventBroadcaster; import com.bourre.events.EventType; import com.bourre.events.FrontController; import com.bourre.events.IEvent; import fever.commands.LockInteractionCommand; import fever.events.FeverEventList; import fever.utils.Stringifier; /** * Front controller implementation for application events / commands. * *

{@link FeverController} is just a central place to put your * event / command pair.
* Remoting events are declared in {@link fever.events.FeverEventList} * *

Take a look at Pixlib Front Controller API for more * informations. * *

Basic command are already registred in controller like * {@link fever.commands.LockInteractionCommand} with fever.events.FeverEventList#LOCK_INTERACTION} * event. * * @see fever.events.FeverEventList * * @author Romain Ecarnot */ class fever.events.FeverController extends FrontController { //------------------------------------------------------------------------- // Private properties //------------------------------------------------------------------------- private static var _instance : FeverController; //------------------------------------------------------------------------- // Public API //------------------------------------------------------------------------- /** * @return {@link FeverController} instance. */ public static function getInstance() : FeverController { if ( !_instance ) _instance = new FeverController(); return _instance; } /** * Broadcasts passed-in event *
Executes registred command. */ public function broadcastEvent( event : IEvent ) : Void { _oEB.broadcastEvent( event ); } /** * Wrapper for Macromedia {@code EventDispatcher} polymorphism. * * @param o Event object. */ public function dispatchEvent( event : Object ) : Void { _oEB.dispatchEvent( event ); } /** * Shortcut to broacast basic event type without any specific * event structure. * *

Take a look at {@link #broadcastEvent()} to disptach a custom * event. * * @param type Event type to dispatch */ public function fireEventType( type : EventType ) : Void { _oEB.broadcastEvent( new BasicEvent( type ) ); } /** * Returns {@code true} is passed-in {@code event} type has a registred * command in current controller. */ public function isRegistred( type : String ) : Boolean { return _a.containsKey( type.toString() ); } /** * Returns string representation. */ public function toString() : String { return Stringifier.parse( this ); } //------------------------------------------------------------------------- // Private implementation //------------------------------------------------------------------------- /** * Constructor. */ private function FeverController() { super( new EventBroadcaster( this ) ); push( FeverEventList.onLockInteractionEVENT, new LockInteractionCommand() ); } }