Command getting fired twice in module with cairngorm

61 views
Skip to first unread message

gurpreet

unread,
Feb 26, 2010, 6:37:39 AM2/26/10
to Flex India Community
I am loading modules in my application which is based on Cairngorm.
Each of the module has its own frontcontroller. I'm facing an issue
that when a cairngorm event is dispatched within the module, the
command execute() method gets called twice. Has anyone faced this
before?

Really need some help here...

Thanks in advance
gurpreet

Ajay Chhaya

unread,
Feb 26, 2010, 11:37:27 AM2/26/10
to flex_...@googlegroups.com
please check the frontcontroller, if it's instance are being created twice.
---------------------
Ajay Chhaya

www.ajaychhaya.com
--------------------------------



--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.


Vaibhav Seth

unread,
Feb 26, 2010, 11:53:09 AM2/26/10
to flex_...@googlegroups.com
Mapping the events to command is a kind of event listener only.
So, if even if the view goes out of the application, it doesn't mean the handlers attached will also go away. There are possibilities that they will respond even if the view have been removed from the list.
Use the weak-reference true, while adding the command in the controller and use removeCommand() while you unload the module. Also, keep the event names unique across all modules.
--
Thanks,
Vaibhav Seth.

Debabrata Acharjee

unread,
Mar 1, 2010, 4:16:30 AM3/1/10
to Flex India Community
Is your problem fixed? It's a bit tricky to get Modules and
Cairngorm work together. Is your main application also using
Caringorm?

On Feb 26, 9:53 pm, Vaibhav Seth <seth.vaibhav...@gmail.com> wrote:
> Mapping the events to command is a kind of event listener only.
> So, if even if the view goes out of the application, it doesn't mean the
> handlers attached will also go away. There are possibilities that they will
> respond even if the view have been removed from the list.
> Use the weak-reference true, while adding the command in the controller and
> use removeCommand() while you unload the module. Also, keep the event names
> unique across all modules.
>
>
>
> On Fri, Feb 26, 2010 at 11:37 AM, Ajay Chhaya <ajay.fl...@gmail.com> wrote:
> > please check the frontcontroller, if it's instance are being created twice.
> > ---------------------
> > Ajay Chhaya
>
> >www.ajaychhaya.com
> > --------------------------------
>

> > On Fri, Feb 26, 2010 at 5:07 PM, gurpreet <gsmai...@gmail.com> wrote:
>
> >> I am loading modules in my application which is based on Cairngorm.
> >> Each of the module has its own frontcontroller. I'm facing an issue
> >> that when a cairngorm event is dispatched within the module, the
> >> command execute() method gets called twice. Has anyone faced this
> >> before?
>
> >> Really need some help here...
>
> >> Thanks in advance
> >> gurpreet
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Flex India Community" group.
> >> To post to this group, send email to flex_...@googlegroups.com.
> >> To unsubscribe from this group, send email to

> >> flex_india+...@googlegroups.com<flex_india%2Bunsu...@googlegroups.com>


> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/flex_india?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Flex India Community" group.
> > To post to this group, send email to flex_...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > flex_india+...@googlegroups.com<flex_india%2Bunsu...@googlegroups.com>

gurpreet

unread,
Mar 3, 2010, 11:59:05 PM3/3/10
to Flex India Community
Thanks guys for all the inputs.

I was able to fix the issue. What was happening is that on unloading
the module, I was not removing the listed commands for that
controller. On loading the module again, each command would get added
again. So if I unload and load the module 5 times, the command would
get added 5 times.

Now I've added the following function to the module controller and
call it every time the module unloads. This cleans up the commands
list from the controller.

public function removeAllCommands():void
{
for (var key:String in commands)
{
removeCommand(key);

杨小林

unread,
Dec 20, 2012, 1:18:30 AM12/20/12
to flex_...@googlegroups.com, gsma...@gmail.com
Hi,

I encountered this issue too. But I'm not able to fix it. Could you tell me where did you put removeAllCommands() ? Thanks a lot.

在 2010年3月4日星期四UTC+8下午12时59分05秒,gurpreet写道:

Pratimesh Bharude

unread,
Dec 21, 2012, 3:30:53 AM12/21/12
to flex_...@googlegroups.com
In controller
Reply all
Reply to author
Forward
0 new messages