Hey Kevin.
Well my problem was different than yours but I will answer your
question as best I can.
What I would check are:
Make sure your controller is being instantiated on your Main.mxml
page. Like this:
<!-- the FrontController, containing Commands specific to this
appliation -->
<control:MyController id="MyController" />
**NOTE** make sure control: is mapped to the directory you have your
FrontController class in.
If you have the reference to the controller, being instantiated on the
Main.mxml, then move on to the controller itself. Be sure you have a
constructor, and an initialize commands method, that has registered
events, with commands. Using the CairngormEventDispatcher, will fire
your events, but only the FrontController you instantiate will hear
them. At the same time if you are dispatching a CairngormEvent using
the standard EventDispatcher, it will NOT send the event to the
FrontController. This is useful for firing events in a standard way,
for the grid details panel for example, but not when you dont actually
register the Event to a command.
The constructor:
public function MyController()
{
initialiseCommands();
}
The initilseCommands() method:
public function initialiseCommands() : void
{
addCommand( Event1.EVENT_LOGIN, LoginCommand );
addCommand( Event2.EVENT_GET_AUTHENTICATION,
GetAuthenticationCommand );
}
In your commands execute method write a simple popup to test:
execute(){
Alert.show("Testing");
}
Just to see whats happening.
As for your question about the static variables. I dont know that it
makes much difference. I prefer to put mine on the events, simply
because I dont like having a lot of statics attached to my controller,
but it might make sense should you get alot to have them all in one
place. I also do things perhaps a little differently, by creating
general events, such as an AuthenticateEvent, with three Statics, like
LOGIN, LOGOUT, and GETAUTHENTICATED. This way I have one event that
handles multiple functions, but it could get complicated managing it,
should your events require lots of member variables for data payload.
Hope this helps.
--- In [email protected], Kevin <[EMAIL PROTECTED]> wrote:
>
> I am actually looking at the event called in the Main.mxml file
>
> -----------------------
> private function onCreationComplete() : void
> {
> CairngormEventDispatcher.getInstance().dispatchEvent( new
> CairngormEvent( GetProductsEvent.EVENT_GET_PRODUCTS ) );
> }
> -----------------------
>
> I will look at my code again today and see if I can find the error.
> I am getting no error message, the event just doesn't fire.
>
> I have also noticed in the store code, that they store the static
> event variable
>
> -----------------------
> public static var EVENT_GET_PRODUCTS : String = "getProducts";
> -----------------------
>
> in the Event class, while most other Cairngorm examples store this in
> the Controller. Is this just personal preference or is there a more
> significant reason for this?
>
> - Kevin
>
>
> On Jan 10, 2007, at 8:30 AM, cardinalflexjeremy wrote:
>
> > There actually is a problem in the Cairngorm store code. I found it
> > when trying to dispatch an event using it.
> >
> > There are two sections that dispatch events, one works and one does
> > not. The section with the graphical tile list dispatches a cairngorm
> > event, but not using the CairngormEventDispatcher to update the
> > details.
> >
> > The textual list uses a different method, since I had a grid object
> > updating the details panel, I used that code, and it does not fire.
> >
> > The rule of thumb is, if you want to dispatch and event that is not
> > registered on your controller, you do not use the
> > CairgormEventDispatcher, but the standard EventDispatcher, regardless
> > of whether or not your event is a cairngorm event.
> >
> > If you are using the code that resides in the textual product list to
> > dispatch an event to update the details it will not work, the code is
> > wrong. Unless they changed it recently. If you download it, compile
> > it, and run it, switch to the textual view, it will not update the
> > details panel. However the visual graphical tile list will work.
> > Because they use different event dispatching.
> >
> > Hope this helps. This was a problem for me too. This may not be what
> > your doing, but at least make sure you did not copy the code from the
> > textual product list to dispatch the event or it wont work properly.
> >
> > Jeremy Sanders
> > Cardinal Solutions Group
> > Flex Application Developer
> > [EMAIL PROTECTED]
> >
> > --- In [email protected], "Stembert Olivier \(BIL\)"
> > <olivier.stembert@> wrote:
> > >
> > > What's the description of the error?
> > > Are you sure the controller has been instantiated?
> > >
> > > Olivier
> > >
> > > ________________________________
> > >
> > > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On
> > > Behalf Of Kevin
> > > Sent: Wednesday, January 10, 2007 12:21 AM
> > > To: [email protected]
> > > Subject: [flexcoders] Event calling in Cairngorm 2.1 - Newbie
> > question.
> > >
> > >
> > >
> > > I am trying to follow the 2.1 store as a model to understand the
> > > cairngorm structure and I am getting a constant error in trying to
> > > dispatch an event. I copied the example code almost exactly, but
> > i get
> > > seen to get the even to fire. I don't know if the problem is in my
> > > FrontController or my event.
> > >
> > > Any help you can offer is much appreciated.
> > >
> > > Thank, Kevin
> > >
> > > -------------------
> > >
> > > I have this in my main.mxml file
> > >
> > > private function loadGroupList() : void
> > > {
> > > CairngormEventDispatcher.getInstance().dispatchEvent( new
> > > CairngormEvent( GetGroupListEvent.EVENT_GET_GROUP_LIST ) );
> > > }
> > >
> > >
> > >
> > > and then in my event file:
> > >
> > > import flash.events.Event;
> > > import com.adobe.cairngorm.control.CairngormEvent;
> > >
> > > public class GetGroupListEvent extends CairngormEvent
> > > {
> > > public static var EVENT_GET_GROUP_LIST : String = "getGroupList";
> > >
> > > //public var position : int;
> > >
> > >
> > >
> > >
> > > /**
> > > * Constructor.
> > > */
> > > public function GetGroupListEvent()
> > > {
> > > super( EVENT_GET_GROUP_LIST );
> > > }
> > >
> > >
> > >
> > >
> > > /**
> > > * Override the inherited clone() method, but don't return any
> > > state.
> > > */
> > > override public function clone() : Event
> > > {
> > > return new GetGroupListEvent();
> > > }
> > > }
> > >
> > >
> > >
> > >
> > > and my controller:
> > >
> > >
> > > import com.adobe.cairngorm.control.FrontController;
> > > //import the command folder
> > > import com.onefoot.dbocl.command.*
> > > //import each event
> > > import com.onefoot.dbocl.event.GetGroupListEvent;
> > >
> > >
> > >
> > >
> > > /**
> > > * @version $Revision: $
> > > */
> > > public class DboclController extends FrontController
> > > {
> > > public function DboclController()
> > > {
> > > initialiseCommands();
> > > }
> > >
> > >
> > >
> > >
> > > public function initialiseCommands() : void
> > > {
> > > addCommand( GetGroupListEvent.EVENT_GET_GROUP_LIST,
> > GetGroupListCommand
> > > );
> > > }
> > > }
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > ---------------------
> > >
> > > An electronic message is not binding on its sender.
> > >
> > > Any message referring to a binding engagement must be confirmed in
> > > writing and duly signed.
> > >
> > > ---------------------
> > >
> > >
> > >
> > >
> > > ---------------------
> > > An electronic message is not binding on its sender.
> > > Any message referring to a binding engagement must be confirmed in
> > writing and duly signed.
> > > ---------------------
> > >
> >
> >
> >
>