So I'll answer this myself as I found the answer Its in the docs!

https://apache.github.io/royale-docs/libraries/crux/event-handling

You need to define a variable in the class:
[Dispatcher]
public var dispatcher:IEventDispatcher;

and then call it like this:
        dispatcher.dispatchEvent(myEvent);

D

On 2021/03/13 17:27:13, David Slotemaker de Bruine 
<[email protected]> wrote: 
> Hi all,
> 
> I am not sure if this is CRUX correct. I have a loginEvent that checks the 
> user details on the server via the UsuarioController, if the result of the 
> service call is correct I want to call a CommonEvent that will call the 
> CommonController. I have tried creating an Event and dispatching it directly 
> from the UsuarioController, but I get the following error:
> 
> Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of 
> type 'Event'.
> 
> When debugging the __proto__ of the event is org.apache.royale.events.Event.
> 
> I am creating and dispatching like this in the UsuarioController.
> 
> private function handleLoginResult( event : ResultEvent ) : void
>               {       
>                       appModel.currentUsuario  = event.result as UsuarioVO;   
>                       appModel.currentUsuario = 
> RolHelper.fillBooleansRolUsuario(appModel.currentUsuario);
>                       
>                       appModel.selectedUsuario = appModel.currentUsuario;
>                       appModel.selectedState = AppModel.STATE_MAIN;
> 
>                               try
>                               {
>                                       var 
> eventLoadConfiguraciones:CommonEvent = new 
> CommonEvent(CommonEvent.EVENT_LOAD_CONFIGURACIONES);
>                                       dispatchEvent(eventLoadConfiguraciones);
>                               }
>                               catch(e:Error)
>                               {
>                                       Alert.show(e.message);                  
>                               }
>                       }
>               }
> 
> What is the correct way to do this?
> 
> 

Reply via email to