accessing the event parameters inside the Command mapped by that event.

vishwas.gagrani's Avatar

vishwas.gagrani

28 Jul, 2012 06:07 PM

I am dispatching a CONFIGURE event, with some parameters in AppContext.as

AppContext.as :

    override public function startup():void
    {

        // Map some Commands to Events
        commandMap.mapEvent(ConfigureDatabaseEvent.CONFIGURE, ConfigureDatabaseCommand);
         ..............
                ................    
         ..............
                ................    
                dispatchEvent(new ConfigureDatabaseEvent(ConfigureDatabaseEvent.CONFIGURE, directoryName_Str)) ;

          }

Now i wanna access the parameter value of "directoryName_Str", passed by the event as body inside ConfigureDatabaseCommand.as

I am wondering how to do that ?

Thnx
V.

  1. 1 Posted by neil on 28 Jul, 2012 06:26 PM

    neil's Avatar

    inject the event into the command.

    in your ConfigureDatabaseCommand:

    [Inject]
    public var event:Event
    
    public function execute():void{
        const e:ConfigureDatabaseEvent = event as ConfigureDatabaseEvent
    }
    

    OR event better:

    add the Event Class reference to the command mapping

     commandMap.mapEvent(ConfigureDatabaseEvent.CONFIGURE, ConfigureDatabaseCommand, e:ConfigureDatabaseEvent );
    

    and in your command:

    [Inject]
    public var e:ConfigureDatabaseEvent 
    
    public function execute():void{
    
    }
    
  2. Ondina D.F. closed this discussion on 25 Aug, 2012 02:41 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac