[flexcoders] Re: How to register a dynamicEvent in an Actionscript class

2009-01-13 Thread kylewburke
I don't know if Cairgorm is anything like PureMVC but if you have a
reference to the UIComponent that you want to dispatch the event, you
would so something like this:

MXML:
MyComponent
mx:Metadata
[Event(name=rowSelected, type=mx.events.DynamicEvent)]
/mx:Metadata
/MyComponent

Then, in AS:
var myComponent:MyComponent;
myComponent.dispatchEvent(rowSelected);

Then again, I could be completely misconstruing what you're trying to
do.  :)

--- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote:

 In case this helps anyone else - I got this to work.
 
 Had to reference the moduleLoader through the application - so when I
 dispatch the dynamicEvent from inside the CairgormCommand's execute
 method it looks like this:
 
 initCompleteEvent = new DynamicEvent(initCompleted,true);

Application.application.myModuleLoader.child.dispatchEvent(initCompleteEvent);
 
 --- In flexcoders@yahoogroups.com, flexcoder2008 djohnson29@ wrote:
 
  Well, I want to dispatch the dynamicEvent from the actionscript class
  (which is a Cairngorm command) and I want my module to listen for that
  event.  
  
  Since the module event handler code is not being hit, I thought I
  might need to register this event with the compiler (perhaps my
  terminology is wrong - sorry).  I know that when using a component,
  you use the [Event] metadata tag to announce that the component
  dispatches a particular event.  I thought that I might have to do the
  same thing with an actionscript class.  
  
  
  
  --- In flexcoders@yahoogroups.com, kylewburke monkeys@ wrote:
  
   What do you mean by register?  Do you want to listen for that
event
   or dispatch one?
   
   --- In flexcoders@yahoogroups.com, flexcoder2008 djohnson29@
 wrote:
   
I have seen numerous examples of registering a dynamicEvent in a
component's mxml such as:

[Event (name=rowSelected, type=mx.events.DynamicEvent)]

If I have an actionscript class that dispatches a
dynamicEvent, what
is the syntax for this?

I want to dispatch a dynamicEvent from an actionscript class,
and I
want my module to listen for that event.
   
  
 





[flexcoders] Re: How to register a dynamicEvent in an Actionscript class

2009-01-12 Thread flexcoder2008
Hmmm, this is the way I have done it - but my event handler is not firing.

I am dispatching my DynamicEvent from a Cairngorm command - in the
execute method I have:

var evt:DynamicEvent = new DynamicEvent(initCompleted);
dispatchEvent(evt);


in my module's creationComplete handler I have this code:

this.addEventListener(initCompleted,initCompletedHandler);



Then in the module's script block I have the event handler

private function initCompletedHandler(event:DynamicEvent):void{
}


This handler never gets hit.


--- In flexcoders@yahoogroups.com, Nate Beck n...@... wrote:

 It's exactly the same as a standard Event.  As you can see in the
Language
 Reference (
 http://livedocs.adobe.com/flex/3/langref/mx/events/DynamicEvent.html):
 
 var event:DynamicEvent = new DynamicEvent(credentialsChanged);
   event.name = name;
   event.passsword = password; // misspelling won't be caught!
   dispatchEvent(event);
 
 then..
 
 module.addEventListener(credentialsChanged, myHandler);
 
 The DynamicEvent class works exactly like and Event... it just gives
 you the ability to add properties to it at runtime.  If you're going
 to be using the same event over and over again.  You're better off
 just creating a custom event

(http://livedocs.adobe.com/flex/3/html/help.html?content=createevents_1.html#110674).
 
 If you do not identify an event in the class file with the [Event]
 metadata tag, the MXML compiler generates an error if you try to use
 the event name in MXML. Any component can register an event listener
 for the event in ActionScript by using the addEventListener()method,
 even if you omit the [Event] metadata tag.
 
 HTH,
 
 Nate
 
 On Mon, Jan 12, 2009 at 11:07 AM, flexcoder2008 djohnso...@...wrote:
 
I have seen numerous examples of registering a dynamicEvent in a
  component's mxml such as:
 
  [Event (name=rowSelected, type=mx.events.DynamicEvent)]
 
  If I have an actionscript class that dispatches a dynamicEvent, what
  is the syntax for this?
 
  I want to dispatch a dynamicEvent from an actionscript class, and I
  want my module to listen for that event.
 
   
 
 
 
 
 -- 
 
 Cheers,
 Nate
 
 http://blog.natebeck.net





[flexcoders] Re: How to register a dynamicEvent in an Actionscript class

2009-01-12 Thread kylewburke
What do you mean by register?  Do you want to listen for that event
or dispatch one?

--- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote:

 I have seen numerous examples of registering a dynamicEvent in a
 component's mxml such as:
 
 [Event (name=rowSelected, type=mx.events.DynamicEvent)]
 
 If I have an actionscript class that dispatches a dynamicEvent, what
 is the syntax for this?
 
 I want to dispatch a dynamicEvent from an actionscript class, and I
 want my module to listen for that event.





[flexcoders] Re: How to register a dynamicEvent in an Actionscript class

2009-01-12 Thread flexcoder2008
Well, I want to dispatch the dynamicEvent from the actionscript class
(which is a Cairngorm command) and I want my module to listen for that
event.  

Since the module event handler code is not being hit, I thought I
might need to register this event with the compiler (perhaps my
terminology is wrong - sorry).  I know that when using a component,
you use the [Event] metadata tag to announce that the component
dispatches a particular event.  I thought that I might have to do the
same thing with an actionscript class.  



--- In flexcoders@yahoogroups.com, kylewburke monk...@... wrote:

 What do you mean by register?  Do you want to listen for that event
 or dispatch one?
 
 --- In flexcoders@yahoogroups.com, flexcoder2008 djohnson29@ wrote:
 
  I have seen numerous examples of registering a dynamicEvent in a
  component's mxml such as:
  
  [Event (name=rowSelected, type=mx.events.DynamicEvent)]
  
  If I have an actionscript class that dispatches a dynamicEvent, what
  is the syntax for this?
  
  I want to dispatch a dynamicEvent from an actionscript class, and I
  want my module to listen for that event.
 





Re: [flexcoders] Re: How to register a dynamicEvent in an Actionscript class

2009-01-12 Thread Nate Beck
Events don't bubble by default.
So if you're depending on the Cairngorm Front Controller to pick them up,
and the object dispatching the event isn't directly below the Application,
you need to enable event bubbling.

new DynamicEvent(myType, true);

Cheers,
Nate

On Mon, Jan 12, 2009 at 11:48 AM, flexcoder2008 djohnso...@yahoo.comwrote:

   Well, I want to dispatch the dynamicEvent from the actionscript class
 (which is a Cairngorm command) and I want my module to listen for that
 event.

 Since the module event handler code is not being hit, I thought I
 might need to register this event with the compiler (perhaps my
 terminology is wrong - sorry). I know that when using a component,
 you use the [Event] metadata tag to announce that the component
 dispatches a particular event. I thought that I might have to do the
 same thing with an actionscript class.

 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,
 kylewburke monk...@... wrote:
 
  What do you mean by register? Do you want to listen for that event
  or dispatch one?
 
  --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,
 flexcoder2008 djohnson29@ wrote:
  
   I have seen numerous examples of registering a dynamicEvent in a
   component's mxml such as:
  
   [Event (name=rowSelected, type=mx.events.DynamicEvent)]
  
   If I have an actionscript class that dispatches a dynamicEvent, what
   is the syntax for this?
  
   I want to dispatch a dynamicEvent from an actionscript class, and I
   want my module to listen for that event.
  
 

  




-- 

Cheers,
Nate

http://blog.natebeck.net


[flexcoders] Re: How to register a dynamicEvent in an Actionscript class

2009-01-12 Thread flexcoder2008
Thanks Nate,

Tried that but it still doesn't work.  I'm basically trying to
dispatch a dynamicEvent from a Cairngorm event and then trying to get
a module to listen for that event.  I don't want this event to be a
CiarngormEvent to be handled by the FrontController and the Command
object.  In other words, I want the module that originally dispatched
the CairngormEvent to handle the DynamicEvent that gets raised by the
CairngormCommand.

I just can't seem to get this to work.  




--- In flexcoders@yahoogroups.com, Nate Beck n...@... wrote:

 Events don't bubble by default.
 So if you're depending on the Cairngorm Front Controller to pick
them up,
 and the object dispatching the event isn't directly below the
Application,
 you need to enable event bubbling.
 
 new DynamicEvent(myType, true);
 
 Cheers,
 Nate
 
 On Mon, Jan 12, 2009 at 11:48 AM, flexcoder2008 djohnso...@...wrote:
 
Well, I want to dispatch the dynamicEvent from the actionscript
class
  (which is a Cairngorm command) and I want my module to listen for that
  event.
 
  Since the module event handler code is not being hit, I thought I
  might need to register this event with the compiler (perhaps my
  terminology is wrong - sorry). I know that when using a component,
  you use the [Event] metadata tag to announce that the component
  dispatches a particular event. I thought that I might have to do the
  same thing with an actionscript class.
 
  --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,
  kylewburke monkeys@ wrote:
  
   What do you mean by register? Do you want to listen for that event
   or dispatch one?
  
   --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,
  flexcoder2008 djohnson29@ wrote:
   
I have seen numerous examples of registering a dynamicEvent in a
component's mxml such as:
   
[Event (name=rowSelected, type=mx.events.DynamicEvent)]
   
If I have an actionscript class that dispatches a
dynamicEvent, what
is the syntax for this?
   
I want to dispatch a dynamicEvent from an actionscript class,
and I
want my module to listen for that event.
   
  
 
   
 
 
 
 
 -- 
 
 Cheers,
 Nate
 
 http://blog.natebeck.net





[flexcoders] Re: How to register a dynamicEvent in an Actionscript class

2009-01-12 Thread flexcoder2008
In case this helps anyone else - I got this to work.

Had to reference the moduleLoader through the application - so when I
dispatch the dynamicEvent from inside the CairgormCommand's execute
method it looks like this:

initCompleteEvent = new DynamicEvent(initCompleted,true);
Application.application.myModuleLoader.child.dispatchEvent(initCompleteEvent);

--- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote:

 Well, I want to dispatch the dynamicEvent from the actionscript class
 (which is a Cairngorm command) and I want my module to listen for that
 event.  
 
 Since the module event handler code is not being hit, I thought I
 might need to register this event with the compiler (perhaps my
 terminology is wrong - sorry).  I know that when using a component,
 you use the [Event] metadata tag to announce that the component
 dispatches a particular event.  I thought that I might have to do the
 same thing with an actionscript class.  
 
 
 
 --- In flexcoders@yahoogroups.com, kylewburke monkeys@ wrote:
 
  What do you mean by register?  Do you want to listen for that event
  or dispatch one?
  
  --- In flexcoders@yahoogroups.com, flexcoder2008 djohnson29@
wrote:
  
   I have seen numerous examples of registering a dynamicEvent in a
   component's mxml such as:
   
   [Event (name=rowSelected, type=mx.events.DynamicEvent)]
   
   If I have an actionscript class that dispatches a dynamicEvent, what
   is the syntax for this?
   
   I want to dispatch a dynamicEvent from an actionscript class, and I
   want my module to listen for that event.